browser-sync-connect
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -10,23 +10,9 @@ (function(exports) { | ||
port = port || 3e3; | ||
version = version || "0.9.1"; | ||
var hasConnector = parseFloat(version) >= .9; | ||
var socketUrl = "//" + host + ":" + port; | ||
var clientUrl = "//" + host + ":" + (port + 1); | ||
version = version || "1.3.6"; | ||
var clientUrl = "//" + host + ":" + port; | ||
var script = document.createElement("script"); | ||
script.src = socketUrl + "/socket.io/socket.io.js"; | ||
script.defer = hasConnector; | ||
script.src = clientUrl + "/browser-sync-client." + version + ".js"; | ||
script.async = true; | ||
script.id = id; | ||
script.onload = function() { | ||
var s; | ||
if (!hasConnector) { | ||
s = document.createElement("script"); | ||
s.innerHTML = 'var ___socket___ = io.connect("' + socketUrl + '");'; | ||
document.body.appendChild(s); | ||
} | ||
s = document.createElement("script"); | ||
s.src = clientUrl + "/client/browser-sync-client." + version + ".js"; | ||
s.defer = hasConnector; | ||
document.body.appendChild(s); | ||
}; | ||
document.body.appendChild(script); | ||
document.head.appendChild(script); | ||
}; | ||
@@ -33,0 +19,0 @@ typeof module !== "undefined" && module.exports ? module.exports = browserSyncConnect : typeof define === "function" && define.amd ? define([], function() { |
@@ -1,1 +0,1 @@ | ||
!function(exports){"use strict";var browserSyncConnect=function(host,version,port){var id="__bs_script__";if(!document.getElementById(id)){host=host||window.location.hostname,port=port||3e3,version=version||"0.9.1";var hasConnector=parseFloat(version)>=.9,socketUrl="//"+host+":"+port,clientUrl="//"+host+":"+(port+1),script=document.createElement("script");script.src=socketUrl+"/socket.io/socket.io.js",script.defer=hasConnector,script.id=id,script.onload=function(){var s;hasConnector||(s=document.createElement("script"),s.innerHTML='var ___socket___ = io.connect("'+socketUrl+'");',document.body.appendChild(s)),s=document.createElement("script"),s.src=clientUrl+"/client/browser-sync-client."+version+".js",s.defer=hasConnector,document.body.appendChild(s)},document.body.appendChild(script)}};"undefined"!=typeof module&&module.exports?module.exports=browserSyncConnect:"function"==typeof define&&define.amd?define([],function(){return browserSyncConnect}):exports.browserSyncConnect=browserSyncConnect}(this); | ||
!function(exports){"use strict";var browserSyncConnect=function(host,version,port){var id="__bs_script__";if(!document.getElementById(id)){host=host||window.location.hostname,port=port||3e3,version=version||"1.3.6";var clientUrl="//"+host+":"+port,script=document.createElement("script");script.src=clientUrl+"/browser-sync-client."+version+".js",script.async=!0,script.id=id,document.head.appendChild(script)}};"undefined"!=typeof module&&module.exports?module.exports=browserSyncConnect:"function"==typeof define&&define.amd?define([],function(){return browserSyncConnect}):exports.browserSyncConnect=browserSyncConnect}(this); |
{ | ||
"name": "browser-sync-connect", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"description": "connect to browser sync without copying the script snippets to the html source", | ||
@@ -5,0 +5,0 @@ "main": "src/browser-sync-connect.js", |
@@ -6,3 +6,8 @@ browser-sync-connect | ||
just one line to add the browser-sync script snippts dynamicly: | ||
<pre> | ||
browserSyncConnect(); | ||
</pre> | ||
regularly i use gulp and gulp connect to run a testserver on port 9000 on my machine and do: | ||
@@ -9,0 +14,0 @@ |
(function(exports) { | ||
'use strict'; | ||
'use strict'; | ||
var browserSyncConnect = function(host, version, port) { | ||
var browserSyncConnect = function(host, version, port) { | ||
var id = '__bs_script__'; | ||
var id = '__bs_script__'; | ||
if (document.getElementById(id)) { | ||
return; | ||
} | ||
if (document.getElementById(id)) { | ||
return; | ||
} | ||
host = host || window.location.hostname; | ||
port = port || 3000; | ||
version = version || '0.9.1'; | ||
host = host || window.location.hostname; | ||
port = port || 3000; | ||
version = version || '1.3.6'; | ||
var hasConnector = parseFloat(version) >= 0.9; | ||
var clientUrl = '//' + host + ':' + port; | ||
var socketUrl = '//' + host + ':' + port; | ||
var clientUrl = '//' + host + ':' + (port + 1); | ||
var script = document.createElement('script'); | ||
script.src = clientUrl + '/browser-sync-client.' + version + '.js'; | ||
script.async = true; | ||
script.id = id; | ||
var script = document.createElement('script'); | ||
script.src = socketUrl + '/socket.io/socket.io.js'; | ||
script.defer = hasConnector; | ||
script.id = id; | ||
document.head.appendChild(script); | ||
}; | ||
script.onload = function() { | ||
var s; | ||
(typeof module !== 'undefined' && module.exports) ? (module.exports = browserSyncConnect) : (typeof define === 'function' && define.amd ? (define([], function() { | ||
return browserSyncConnect; | ||
})) : (exports.browserSyncConnect = browserSyncConnect)); | ||
if (!hasConnector) { | ||
s = document.createElement('script'); | ||
s.innerHTML = 'var ___socket___ = io.connect("' + socketUrl + '");'; | ||
document.body.appendChild(s); | ||
} | ||
s = document.createElement('script'); | ||
s.src = clientUrl + '/client/browser-sync-client.' + version + '.js'; | ||
s.defer = hasConnector; | ||
document.body.appendChild(s); | ||
}; | ||
document.body.appendChild(script); | ||
}; | ||
(typeof module !== 'undefined' && module.exports) ? (module.exports = browserSyncConnect) : (typeof define === 'function' && define.amd ? (define([], function() { | ||
return browserSyncConnect; | ||
})) : (exports.browserSyncConnect = browserSyncConnect)); | ||
}(this)); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21
3836
41