Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

browser-sync

Package Overview
Dependencies
Maintainers
1
Versions
300
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browser-sync - npm Package Compare versions

Comparing version 0.3.0 to 0.3.1

9

lib/browser-sync-client.js

@@ -401,2 +401,4 @@ 'use strict';

var url;
var scrollTop = ghost.getScrollTop(); // Get y position of scroll

@@ -415,5 +417,8 @@ var newScroll = new Date().getTime();

scope.ghostMode.lastScroll = newScroll;
url = window.location.host + window.location.pathname;
ghost.emitEvent("scroll",
{
pos: scrollTop, url: window.location.href
pos: scrollTop, url: url
});

@@ -503,3 +508,3 @@ }

socket.on("scroll:update", function (data) {
if (data.url === window.location.href) {
if (data.url === window.location.host + window.location.pathname) {
scope.ghostMode.enabled = false;

@@ -506,0 +511,0 @@ window.scrollTo(0, data.position);

@@ -1,1 +0,1 @@

"use strict";!function(a,b){var c={ghostMode:{enabled:!0,cache:{}}},d={tagNames:{css:"link",jpg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}},e={processOptions:function(a,b,c,d){a.options=b,b.ghostMode&&this.initGhostMode(b.ghostMode,c,d)},initGhostMode:function(a,b,d){if(a.links&&g.initClickEvents(c,b,d.click),a.scroll&&g.initEvents(c,["scroll"],b,d),a.forms)for(var e=g.getInputs(),f=[[e.texts,"keyup","keyup"],[e.radios,"click","forceChange"],[e.radios,"change","radioChange"],[e.checkboxes,"click","forceChange"],[e.checkboxes,"change","checkboxChange"],["textarea","keyup","keyup"],["select","change","selectChange"],["form","submit","formSubmit"],["form","reset","formReset"]],h=0,i=f.length;i>h;h+=1)g.addBrowserEvents(f[h][0],f[h][1],d[f[h][2]],b)},reloadEvent:function(a,b,c){var d;if(b.url&&c.reloadBrowser(!0),b.assetFileName&&b.fileExtension){var e=this.getElems(b.fileExtension),f=this.getMatches(e.elems,b.assetFileName,e.attr);"undefined"!=typeof f&&(d=c.swapFile(f,e.attr))}return d},getElems:function(a){var b=this.getTagName(a),c=this.getAttr(b);return{elems:document.getElementsByTagName(b),attr:c}},getTagName:function(a){return d.tagNames[a]},getAttr:function(a){return d.attrs[a]},getMatches:function(a,b,c){for(var d,e=0,f=a.length;f>e;e+=1)-1!==a[e][c].indexOf(b)&&(d=e);return a[d]}},f={reloadBrowser:function(a){a&&location.reload()},swapFile:function(a,b){var c=a[b],d=/^[^\?]+(?=\?)/.exec(c);d&&(c=d[0]);var e=(new Date).getTime();return a[b]=c+"?rel="+e,{elem:a,timeStamp:e}}},g={getScroll:function(){if(void 0!==a.pageYOffset)return[a.pageXOffset,a.pageYOffset];var b,c,d=document,e=d.documentElement,f=d.body;return b=e.scrollLeft||f.scrollLeft||0,c=e.scrollTop||f.scrollTop||0,[b,c]},getScrollTop:function(){return this.getScroll()[1]},setScrollTop:function(b,c){b.enabled=!1,a.scrollTo(0,c)},checkCache:function(a,b){var c;return a[b]?a[b].elem:(a.called=a.called?a.called+=1:1,c=document.getElementById(b),c?(a[b]={},a[b].elem=c,c):!1)},initClickEvents:function(a,b,c){for(var d=document.getElementsByTagName("a"),e=0,f=d.length;f>e;e+=1)this.composeElementEvent(d[e],b,"click",c)},initEvents:function(a,b,c,d){for(var e="scroll",f=0,g=b.length;g>f;f+=1)b[f]===e&&this.composeSingleEvent(c,e,d[e])},composeSingleEvent:function(b,c,d){a[b.eventListener](b.prefix+c,d,!1)},composeElementEvent:function(a,b,c,d){a[b.eventListener](b.prefix+"click",d,!1)},emitEvent:function(a,c){b.emit(a,c)},addBrowserEvents:function(a,b,c,d){"string"==typeof a&&(a=document.getElementsByTagName(a));for(var e=0,f=a.length;f>e;e+=1)a[e][d.eventListener](d.prefix+b,c,!1)},getHref:function(a,b){var c,d=a.tagName;return c=b&&b.href?b.href:"A"===d?a.href:this.getParentHref(a,5)},getParentHref:function(a,b){for(var c,d=function(a){return"A"===a.parentNode.tagName?a.parentNode.href:a.parentNode},e=a,f=0;b>f;f+=1){if(c=d(e),"string"==typeof c)return c;e=c}return!1},getInputs:function(){for(var a=document.getElementsByTagName("input"),b=[],c=[],d=[],e=0,f=a.length;f>e;e+=1)"text"===a[e].type&&b.push(a[e]),"radio"===a[e].type&&c.push(a[e]),"checkbox"===a[e].type&&d.push(a[e]);return{texts:b,radios:c,checkboxes:d}},listeners:{scroll:function(){var b=g.getScrollTop(),d=(new Date).getTime();c.ghostMode.lastScroll||(c.ghostMode.scrollTop=b[0],c.ghostMode.lastScroll=(new Date).getTime()),d>c.ghostMode.lastScroll+50&&c.ghostMode.enabled&&(c.ghostMode.lastScroll=d,g.emitEvent("scroll",{pos:b,url:a.location.href})),c.ghostMode.enabled=!0},click:function(a){var b={url:g.getHref(a.target||a.srcElement,this)};g.emitEvent("location",b)},keyup:function(a){var b=a.target||a.srcElement;b.id&&g.emitEvent("input:type",{id:b.id,value:b.value})},forceChange:function(){this.blur(),this.focus()},radioChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:radio",{id:b.id,value:b.value})},checkboxChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:checkbox",{id:b.id,checked:b.checked})},selectChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:select",{id:b.id,value:b.value})},formSubmit:function(a){var b=a.target||a.srcElement;g.emitEvent("form:submit",{id:b.id})},formReset:function(a){var b=a.target||a.srcElement;g.emitEvent("form:reset",{id:b.id})}},utils:{eventListener:a.addEventListener?"addEventListener":"attachEvent",removeEventListener:a.removeEventListener?"removeEventListener":"detachEvent",prefix:a.addEventListener?"":"on"}};a.__karma__&&(a.browserSync=e,a.browserSyncActions=f,a.ghost=g,a.scope=c,b.on=function(){}),b.on("connection",function(a){e.processOptions(c,a,g.utils,g.listeners)}),b.on("reload",function(a){a&&e.reloadEvent(c,a,f)}),b.on("location:update",function(b){b.url&&(a.location=b.url)}),b.on("scroll:update",function(b){b.url===a.location.href&&(c.ghostMode.enabled=!1,a.scrollTo(0,b.position))}),b.on("input:update",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.value=a.value}),b.on("input:update:radio",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.checked=!0}),b.on("input:update:checkbox",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.checked=a.checked}),b.on("form:submit",function(a){c.ghostMode.enabled=!1,document.forms[a.id].submit()}),b.on("form:reset",function(a){c.ghostMode.enabled=!1,document.forms[a.id].reset()})}(window,"undefined"==typeof ___socket___?{}:___socket___);
"use strict";!function(a,b){var c={ghostMode:{enabled:!0,cache:{}}},d={tagNames:{css:"link",jpg:"img",png:"img",svg:"img",gif:"img",js:"script"},attrs:{link:"href",img:"src",script:"src"}},e={processOptions:function(a,b,c,d){a.options=b,b.ghostMode&&this.initGhostMode(b.ghostMode,c,d)},initGhostMode:function(a,b,d){if(a.links&&g.initClickEvents(c,b,d.click),a.scroll&&g.initEvents(c,["scroll"],b,d),a.forms)for(var e=g.getInputs(),f=[[e.texts,"keyup","keyup"],[e.radios,"click","forceChange"],[e.radios,"change","radioChange"],[e.checkboxes,"click","forceChange"],[e.checkboxes,"change","checkboxChange"],["textarea","keyup","keyup"],["select","change","selectChange"],["form","submit","formSubmit"],["form","reset","formReset"]],h=0,i=f.length;i>h;h+=1)g.addBrowserEvents(f[h][0],f[h][1],d[f[h][2]],b)},reloadEvent:function(a,b,c){var d;if(b.url&&c.reloadBrowser(!0),b.assetFileName&&b.fileExtension){var e=this.getElems(b.fileExtension),f=this.getMatches(e.elems,b.assetFileName,e.attr);"undefined"!=typeof f&&(d=c.swapFile(f,e.attr))}return d},getElems:function(a){var b=this.getTagName(a),c=this.getAttr(b);return{elems:document.getElementsByTagName(b),attr:c}},getTagName:function(a){return d.tagNames[a]},getAttr:function(a){return d.attrs[a]},getMatches:function(a,b,c){for(var d,e=0,f=a.length;f>e;e+=1)-1!==a[e][c].indexOf(b)&&(d=e);return a[d]}},f={reloadBrowser:function(a){a&&location.reload()},swapFile:function(a,b){var c=a[b],d=/^[^\?]+(?=\?)/.exec(c);d&&(c=d[0]);var e=(new Date).getTime();return a[b]=c+"?rel="+e,{elem:a,timeStamp:e}}},g={getScroll:function(){if(void 0!==a.pageYOffset)return[a.pageXOffset,a.pageYOffset];var b,c,d=document,e=d.documentElement,f=d.body;return b=e.scrollLeft||f.scrollLeft||0,c=e.scrollTop||f.scrollTop||0,[b,c]},getScrollTop:function(){return this.getScroll()[1]},setScrollTop:function(b,c){b.enabled=!1,a.scrollTo(0,c)},checkCache:function(a,b){var c;return a[b]?a[b].elem:(a.called=a.called?a.called+=1:1,c=document.getElementById(b),c?(a[b]={},a[b].elem=c,c):!1)},initClickEvents:function(a,b,c){for(var d=document.getElementsByTagName("a"),e=0,f=d.length;f>e;e+=1)this.composeElementEvent(d[e],b,"click",c)},initEvents:function(a,b,c,d){for(var e="scroll",f=0,g=b.length;g>f;f+=1)b[f]===e&&this.composeSingleEvent(c,e,d[e])},composeSingleEvent:function(b,c,d){a[b.eventListener](b.prefix+c,d,!1)},composeElementEvent:function(a,b,c,d){a[b.eventListener](b.prefix+"click",d,!1)},emitEvent:function(a,c){b.emit(a,c)},addBrowserEvents:function(a,b,c,d){"string"==typeof a&&(a=document.getElementsByTagName(a));for(var e=0,f=a.length;f>e;e+=1)a[e][d.eventListener](d.prefix+b,c,!1)},getHref:function(a,b){var c,d=a.tagName;return c=b&&b.href?b.href:"A"===d?a.href:this.getParentHref(a,5)},getParentHref:function(a,b){for(var c,d=function(a){return"A"===a.parentNode.tagName?a.parentNode.href:a.parentNode},e=a,f=0;b>f;f+=1){if(c=d(e),"string"==typeof c)return c;e=c}return!1},getInputs:function(){for(var a=document.getElementsByTagName("input"),b=[],c=[],d=[],e=0,f=a.length;f>e;e+=1)"text"===a[e].type&&b.push(a[e]),"radio"===a[e].type&&c.push(a[e]),"checkbox"===a[e].type&&d.push(a[e]);return{texts:b,radios:c,checkboxes:d}},listeners:{scroll:function(){var b,d=g.getScrollTop(),e=(new Date).getTime();c.ghostMode.lastScroll||(c.ghostMode.scrollTop=d[0],c.ghostMode.lastScroll=(new Date).getTime()),e>c.ghostMode.lastScroll+50&&c.ghostMode.enabled&&(c.ghostMode.lastScroll=e,b=a.location.host+a.location.pathname,g.emitEvent("scroll",{pos:d,url:b})),c.ghostMode.enabled=!0},click:function(a){var b={url:g.getHref(a.target||a.srcElement,this)};g.emitEvent("location",b)},keyup:function(a){var b=a.target||a.srcElement;b.id&&g.emitEvent("input:type",{id:b.id,value:b.value})},forceChange:function(){this.blur(),this.focus()},radioChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:radio",{id:b.id,value:b.value})},checkboxChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:checkbox",{id:b.id,checked:b.checked})},selectChange:function(a){var b=a.target||a.srcElement;g.emitEvent("input:select",{id:b.id,value:b.value})},formSubmit:function(a){var b=a.target||a.srcElement;g.emitEvent("form:submit",{id:b.id})},formReset:function(a){var b=a.target||a.srcElement;g.emitEvent("form:reset",{id:b.id})}},utils:{eventListener:a.addEventListener?"addEventListener":"attachEvent",removeEventListener:a.removeEventListener?"removeEventListener":"detachEvent",prefix:a.addEventListener?"":"on"}};a.__karma__&&(a.browserSync=e,a.browserSyncActions=f,a.ghost=g,a.scope=c,b.on=function(){}),b.on("connection",function(a){e.processOptions(c,a,g.utils,g.listeners)}),b.on("reload",function(a){a&&e.reloadEvent(c,a,f)}),b.on("location:update",function(b){b.url&&(a.location=b.url)}),b.on("scroll:update",function(b){b.url===a.location.host+a.location.pathname&&(c.ghostMode.enabled=!1,a.scrollTo(0,b.position))}),b.on("input:update",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.value=a.value}),b.on("input:update:radio",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.checked=!0}),b.on("input:update:checkbox",function(a){c.ghostMode.enabled=!1;var b=g.checkCache(c.ghostMode.cache,a.id);b.checked=a.checked}),b.on("form:submit",function(a){c.ghostMode.enabled=!1,document.forms[a.id].submit()}),b.on("form:reset",function(a){c.ghostMode.enabled=!1,document.forms[a.id].reset()})}(window,"undefined"==typeof ___socket___?{}:___socket___);
{
"name": "browser-sync",
"description": "Live CSS Reload & Browser Syncing",
"version": "0.3.0",
"version": "0.3.1",
"homepage": "https://github.com/shakyshane/browser-sync",

@@ -6,0 +6,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc