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

@zayesh/stay

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zayesh/stay - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

74

build/stay.js
/**
* stay v0.1.1 build Sep 18 2015
* stay v0.1.2 build Sep 18 2015
* https://github.com/vanruesc/stay

@@ -387,9 +387,9 @@ * Copyright 2015 Raoul van Rueschen, Apache-2.0

var response = {};
var response = {meta: {}};
response.title = "Timeout Error";
response.meta.title = "Timeout Error";
if(self.stderr !== null) {
response[self.stderr] = Stay.Error.TIMEOUT;
response[self.stderr] = "<p>" + Stay.Error.TIMEOUT + "</p>";

@@ -476,4 +476,6 @@ } else {

this.update({
title: document.title,
url: window.location.href
meta: {
title: document.title,
url: window.location.href
}
});

@@ -570,34 +572,38 @@

c = this.containers[responseField];
r = response[responseField];
if(c === undefined) {
// Ignore deep structures.
if(typeof r !== "object") {
// No reference exists yet. Find the DOM element and remember it.
c = this.containers[responseField] = document.getElementById(responseField);
c = this.containers[responseField];
}
if(c === undefined) {
r = response[responseField];
// No reference exists yet. Find the DOM element and remember it.
c = this.containers[responseField] = document.getElementById(responseField);
// Check if the field is empty.
if(!r) {
}
while(c.children.length > 0) {
if(c !== null) {
c.removeChild(c.children[0]);
while(c.children.length > 0) {
}
c.removeChild(c.children[0]);
// Let the browser create the DOM elements from the html string.
this.intermediateContainer.innerHTML = r;
}
// Cut & paste them one after another.
while(this.intermediateContainer.children.length > 0) {
// Let the browser create the DOM elements from the html string.
this.intermediateContainer.innerHTML = r;
c.appendChild(this.intermediateContainer.children[0]);
// Cut & paste them one after another.
while(this.intermediateContainer.children.length > 0) {
c.appendChild(this.intermediateContainer.children[0]);
}
contentChanged = true;
}
contentChanged = true;
}

@@ -677,7 +683,7 @@

this._updateView(response);
document.title = response.title;
document.title = response.meta.title;
if(response.url) {
if(response.meta.url) {
this.absolutePath = response.url.replace(this.infix, "");
this.absolutePath = response.meta.url.replace(this.infix, "");

@@ -688,3 +694,3 @@ }

history.pushState({url: this.absolutePath}, response.title, this.absolutePath);
history.pushState({url: this.absolutePath}, response.meta.title, this.absolutePath);

@@ -715,3 +721,3 @@ } else {

var response = {};
var response = {meta: {}};

@@ -726,7 +732,7 @@ if(xhr.readyState === 4) {

response.title = "Parse Error";
response.meta.title = "Parse Error";
if(this.stderr !== null) {
response[this.stderr] = Stay.Error.UNPARSABLE;
response[this.stderr] = "<p>" + Stay.Error.UNPARSABLE + "</p>";

@@ -739,3 +745,3 @@ }

response.url = xhr.responseURL;
response.meta.url = xhr.responseURL;
this.eventReceive.status = xhr.status;

@@ -766,4 +772,4 @@ this.eventReceive.response = response;

Stay.Error = Object.freeze({
TIMEOUT: "<p>The server didn't respond in time. Please try again later!</p>",
UNPARSABLE: "<p>The received content could not be parsed.</p>"
TIMEOUT: "The server didn't respond in time. Please try again later!",
UNPARSABLE: "The received content could not be parsed."
});

@@ -770,0 +776,0 @@

/**
* stay v0.1.1 build Sep 18 2015
* stay v0.1.2 build Sep 18 2015
* https://github.com/vanruesc/stay
* Copyright 2015 Raoul van Rueschen, Apache-2.0
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Stay=e()}(this,function(){"use strict";function t(){this._listeners={}}function e(t){var e=document.createElement("a");return e.href=t,e}function i(e){var n=this;if(t.call(this),this.local=new RegExp("^"+location.protocol+"//"+location.host),this.stderr=null,this.infix="/json",this.timeoutPost=6e4,this.timeoutGet=5e3,this.autoUpdate=!0,void 0!==e&&(void 0!==e.stderr&&(this.stderr=e.stderr),void 0!==e.infix&&(this.infix=e.infix),void 0!==e.timeoutPost&&(this.timeoutPost=e.timeoutPost),void 0!==e.timeoutGet&&(this.timeoutGet=e.timeoutGet),void 0!==e.autoUpdate&&(this.autoUpdate=e.autoUpdate)),this.locked=!1,this.backForward=!1,this.absolutePath=null,this.containers=[],this.intermediateContainer=null,this.navigationListeners=[],this.eventNavigate={type:"navigate"},this.eventReceive={type:"receive",response:null,status:0},this.eventLoad={type:"load"},void 0===XMLHttpRequest)throw new Error("XMLHttpRequest functionality not available.");this.xhr=new XMLHttpRequest,this.xhr.addEventListener("readystatechange",function(t){n._handleResponse(this,t)}),this.xhr.addEventListener("timeout",function(){var t={};t.title="Timeout Error",null!==n.stderr?t[n.stderr]=i.Error.TIMEOUT:console.error(i.Error.TIMEOUT),n.locked=!0,n.update(t)}),window.addEventListener("popstate",function(t){n.locked||null===t.state||(n.backForward=!0,n._navigate({href:t.state.url}))}),this._switchPage=function(t){var e=void 0!==t.preventDefault,i=!1;return"submit"===t.type?i=!0:t.metaKey||t.shiftKey||t.altKey||t.ctrlKey||(void 0!==t.which?i=1===t.which:void 0!==t.button&&(i=0===t.button)),i&&(e&&t.preventDefault(),n.locked||n._navigate(this)),!(i&&!e)},this.update({title:document.title,url:window.location.href}),this._updateListeners()}return t.prototype.apply=function(e){e._listeners={},e.addEventListener=t.prototype.addEventListener,e.hasEventListener=t.prototype.hasEventListener,e.removeEventListener=t.prototype.removeEventListener,e.dispatchEvent=t.prototype.dispatchEvent},t.prototype.addEventListener=function(t,e){void 0===this._listeners[t]&&(this._listeners[t]=[]),-1===this._listeners[t].indexOf(e)&&this._listeners[t].push(e)},t.prototype.hasEventListener=function(t,e){return void 0!==this._listeners[t]&&-1!==this._listeners[t].indexOf(e)},t.prototype.removeEventListener=function(t,e){var i,n;n=this._listeners[t],void 0!==n&&(i=n.indexOf(e),-1!==i&&n.splice(i,1))},t.prototype.dispatchEvent=function(t){var e,i,n;if(n=this._listeners[t.type],void 0!==n)for(t.target=this,e=0,i=n.length;i>e;++e)n[e].call(this,t)},i.prototype=Object.create(t.prototype),i.prototype.constructor=i,i.prototype._navigate=function(t){var i,n,s,r=!1;this.locked=!0,t.action?(this.absolutePath=t.action,i=new FormData(t),r=!0):this.absolutePath=t.href,n=e(this.absolutePath).pathname,"/"!==n.charAt(0)&&(n="/"+n),s="/"===n?this.absolutePath.slice(0,this.absolutePath.length-1)+this.infix+n:this.absolutePath.replace(new RegExp(n),this.infix+n),this.eventNavigate.method=r?"POST":"GET",this.dispatchEvent(this.eventNavigate),this.xhr.open(this.eventNavigate.method,s,!0),r?(this.xhr.timeout=this.timeoutPost,this.xhr.send(i)):(this.xhr.timeout=this.timeoutGet,this.xhr.send())},i.prototype._updateView=function(t){var e,i,n,s=!1;if(null===this.intermediateContainer)this.intermediateContainer=document.createElement("div");else for(;this.intermediateContainer.children.length>0;)this.intermediateContainer.removeChild(this.intermediateContainer.children[0]);for(e in t)if(i=this.containers[e],void 0===i&&(i=this.containers[e]=document.getElementById(e)),n=t[e],!n){for(;i.children.length>0;)i.removeChild(i.children[0]);for(this.intermediateContainer.innerHTML=n;this.intermediateContainer.children.length>0;)i.appendChild(this.intermediateContainer.children[0]);s=!0}s&&this._updateListeners()},i.prototype._updateListeners=function(){var t,e,i=this,n=document.getElementsByTagName("a"),s=document.getElementsByTagName("form");for(t=0,e=this.navigationListeners.length;e>t;++t)this.navigationListeners[t][0].removeEventListener(this.navigationListeners[t][1],i._switchPage);for(t=0,e=n.length;e>t;++t)this.local.test(n[t].href)&&(n[t].addEventListener("click",i._switchPage),this.navigationListeners.push([n[t],"click"]));for(t=0,e=s.length;e>t;++t)this.local.test(s[t].action)&&(s[t].addEventListener("submit",i._switchPage),this.navigationListeners.push([s[t],"submit"]))},i.prototype.update=function(t){this._updateView(t),document.title=t.title,t.url&&(this.absolutePath=t.url.replace(this.infix,"")),this.backForward?this.backForward=!1:history.pushState({url:this.absolutePath},t.title,this.absolutePath),this.eventReceive.response=null,this.dispatchEvent(this.eventLoad),this.locked=!1},i.prototype._handleResponse=function(t){var e={};if(4===t.readyState){try{e=JSON.parse(t.responseText)}catch(n){e.title="Parse Error",null!==this.stderr&&(e[this.stderr]=i.Error.UNPARSABLE),console.error(i.Error.UNPARSABLE,n)}e.url=t.responseURL,this.eventReceive.status=t.status,this.eventReceive.response=e,this.dispatchEvent(this.eventReceive),this.autoUpdate&&this.update(e)}},i.Error=Object.freeze({TIMEOUT:"<p>The server didn't respond in time. Please try again later!</p>",UNPARSABLE:"<p>The received content could not be parsed.</p>"}),i});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.Stay=e()}(this,function(){"use strict";function t(){this._listeners={}}function e(t){var e=document.createElement("a");return e.href=t,e}function i(e){var n=this;if(t.call(this),this.local=new RegExp("^"+location.protocol+"//"+location.host),this.stderr=null,this.infix="/json",this.timeoutPost=6e4,this.timeoutGet=5e3,this.autoUpdate=!0,void 0!==e&&(void 0!==e.stderr&&(this.stderr=e.stderr),void 0!==e.infix&&(this.infix=e.infix),void 0!==e.timeoutPost&&(this.timeoutPost=e.timeoutPost),void 0!==e.timeoutGet&&(this.timeoutGet=e.timeoutGet),void 0!==e.autoUpdate&&(this.autoUpdate=e.autoUpdate)),this.locked=!1,this.backForward=!1,this.absolutePath=null,this.containers=[],this.intermediateContainer=null,this.navigationListeners=[],this.eventNavigate={type:"navigate"},this.eventReceive={type:"receive",response:null,status:0},this.eventLoad={type:"load"},void 0===XMLHttpRequest)throw new Error("XMLHttpRequest functionality not available.");this.xhr=new XMLHttpRequest,this.xhr.addEventListener("readystatechange",function(t){n._handleResponse(this,t)}),this.xhr.addEventListener("timeout",function(){var t={meta:{}};t.meta.title="Timeout Error",null!==n.stderr?t[n.stderr]="<p>"+i.Error.TIMEOUT+"</p>":console.error(i.Error.TIMEOUT),n.locked=!0,n.update(t)}),window.addEventListener("popstate",function(t){n.locked||null===t.state||(n.backForward=!0,n._navigate({href:t.state.url}))}),this._switchPage=function(t){var e=void 0!==t.preventDefault,i=!1;return"submit"===t.type?i=!0:t.metaKey||t.shiftKey||t.altKey||t.ctrlKey||(void 0!==t.which?i=1===t.which:void 0!==t.button&&(i=0===t.button)),i&&(e&&t.preventDefault(),n.locked||n._navigate(this)),!(i&&!e)},this.update({meta:{title:document.title,url:window.location.href}}),this._updateListeners()}return t.prototype.apply=function(e){e._listeners={},e.addEventListener=t.prototype.addEventListener,e.hasEventListener=t.prototype.hasEventListener,e.removeEventListener=t.prototype.removeEventListener,e.dispatchEvent=t.prototype.dispatchEvent},t.prototype.addEventListener=function(t,e){void 0===this._listeners[t]&&(this._listeners[t]=[]),-1===this._listeners[t].indexOf(e)&&this._listeners[t].push(e)},t.prototype.hasEventListener=function(t,e){return void 0!==this._listeners[t]&&-1!==this._listeners[t].indexOf(e)},t.prototype.removeEventListener=function(t,e){var i,n;n=this._listeners[t],void 0!==n&&(i=n.indexOf(e),-1!==i&&n.splice(i,1))},t.prototype.dispatchEvent=function(t){var e,i,n;if(n=this._listeners[t.type],void 0!==n)for(t.target=this,e=0,i=n.length;i>e;++e)n[e].call(this,t)},i.prototype=Object.create(t.prototype),i.prototype.constructor=i,i.prototype._navigate=function(t){var i,n,s,o=!1;this.locked=!0,t.action?(this.absolutePath=t.action,i=new FormData(t),o=!0):this.absolutePath=t.href,n=e(this.absolutePath).pathname,"/"!==n.charAt(0)&&(n="/"+n),s="/"===n?this.absolutePath.slice(0,this.absolutePath.length-1)+this.infix+n:this.absolutePath.replace(new RegExp(n),this.infix+n),this.eventNavigate.method=o?"POST":"GET",this.dispatchEvent(this.eventNavigate),this.xhr.open(this.eventNavigate.method,s,!0),o?(this.xhr.timeout=this.timeoutPost,this.xhr.send(i)):(this.xhr.timeout=this.timeoutGet,this.xhr.send())},i.prototype._updateView=function(t){var e,i,n,s=!1;if(null===this.intermediateContainer)this.intermediateContainer=document.createElement("div");else for(;this.intermediateContainer.children.length>0;)this.intermediateContainer.removeChild(this.intermediateContainer.children[0]);for(e in t)if(n=t[e],"object"!=typeof n&&(i=this.containers[e],void 0===i&&(i=this.containers[e]=document.getElementById(e)),null!==i)){for(;i.children.length>0;)i.removeChild(i.children[0]);for(this.intermediateContainer.innerHTML=n;this.intermediateContainer.children.length>0;)i.appendChild(this.intermediateContainer.children[0]);s=!0}s&&this._updateListeners()},i.prototype._updateListeners=function(){var t,e,i=this,n=document.getElementsByTagName("a"),s=document.getElementsByTagName("form");for(t=0,e=this.navigationListeners.length;e>t;++t)this.navigationListeners[t][0].removeEventListener(this.navigationListeners[t][1],i._switchPage);for(t=0,e=n.length;e>t;++t)this.local.test(n[t].href)&&(n[t].addEventListener("click",i._switchPage),this.navigationListeners.push([n[t],"click"]));for(t=0,e=s.length;e>t;++t)this.local.test(s[t].action)&&(s[t].addEventListener("submit",i._switchPage),this.navigationListeners.push([s[t],"submit"]))},i.prototype.update=function(t){this._updateView(t),document.title=t.meta.title,t.meta.url&&(this.absolutePath=t.meta.url.replace(this.infix,"")),this.backForward?this.backForward=!1:history.pushState({url:this.absolutePath},t.meta.title,this.absolutePath),this.eventReceive.response=null,this.dispatchEvent(this.eventLoad),this.locked=!1},i.prototype._handleResponse=function(t){var e={meta:{}};if(4===t.readyState){try{e=JSON.parse(t.responseText)}catch(n){e.meta.title="Parse Error",null!==this.stderr&&(e[this.stderr]="<p>"+i.Error.UNPARSABLE+"</p>"),console.error(i.Error.UNPARSABLE,n)}e.meta.url=t.responseURL,this.eventReceive.status=t.status,this.eventReceive.response=e,this.dispatchEvent(this.eventReceive),this.autoUpdate&&this.update(e)}},i.Error=Object.freeze({TIMEOUT:"The server didn't respond in time. Please try again later!",UNPARSABLE:"The received content could not be parsed."}),i});

@@ -5,3 +5,3 @@ {

"description": "Stay is a small but effective library for the creation of dynamic xhr-driven web applications.",
"version": "0.1.1",
"version": "0.1.2",
"url": "https://github.com/vanruesc/stay"

@@ -342,3 +342,3 @@ },

"file": "src\\stay.js",
"line": 344,
"line": 346,
"description": "Navigates to the next target uri.",

@@ -360,3 +360,3 @@ "itemtype": "method",

"file": "src\\stay.js",
"line": 397,
"line": 399,
"description": "Updates the containers with the new data.",

@@ -378,3 +378,3 @@ "itemtype": "method",

"file": "src\\stay.js",
"line": 470,
"line": 476,
"description": "Binds event listeners to all links and forms.\nThis method is combined with the cleanup and basically refreshes \nthe navigation listeners.",

@@ -389,3 +389,3 @@ "itemtype": "method",

"file": "src\\stay.js",
"line": 515,
"line": 521,
"description": "Updates the view, the navigation listeners and the history state.\nAlso emits an event to signilise that the page has been loaded.\n\nThe update function needs to be called after each navigation in \norder to unlock the system. This happens by default, but that\nbehaviour can be disabled. It is then the responsibility of the\nprogrammer to call stay.update(response) with the response data\nprovided by the \"receive\" event.",

@@ -405,3 +405,3 @@ "itemtype": "method",

"file": "src\\stay.js",
"line": 556,
"line": 562,
"description": "This function acts when the xhr object changes its readyState.\nThe response will be a json object or an error page. Anything else will \nbe caught as a json parse exception and announced in stderr.",

@@ -423,3 +423,3 @@ "itemtype": "method",

"file": "src\\stay.js",
"line": 605,
"line": 611,
"description": "Enumeration of Error Messages.",

@@ -426,0 +426,0 @@ "itemtype": "property",

{
"name": "@zayesh/stay",
"version": "0.1.1",
"version": "0.1.2",
"description": "Stay is a small but effective library for the creation of dynamic xhr-driven web applications.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/vanruesc/stay",

@@ -245,9 +245,9 @@ import EventDispatcher from "@zayesh/eventdispatcher";

var response = {};
var response = {meta: {}};
response.title = "Timeout Error";
response.meta.title = "Timeout Error";
if(self.stderr !== null) {
response[self.stderr] = Stay.Error.TIMEOUT;
response[self.stderr] = "<p>" + Stay.Error.TIMEOUT + "</p>";

@@ -334,4 +334,6 @@ } else {

this.update({
title: document.title,
url: window.location.href
meta: {
title: document.title,
url: window.location.href
}
});

@@ -428,34 +430,38 @@

c = this.containers[responseField];
r = response[responseField];
if(c === undefined) {
// Ignore deep structures.
if(typeof r !== "object") {
// No reference exists yet. Find the DOM element and remember it.
c = this.containers[responseField] = document.getElementById(responseField);
c = this.containers[responseField];
}
if(c === undefined) {
r = response[responseField];
// No reference exists yet. Find the DOM element and remember it.
c = this.containers[responseField] = document.getElementById(responseField);
// Check if the field is empty.
if(!r) {
}
while(c.children.length > 0) {
if(c !== null) {
c.removeChild(c.children[0]);
while(c.children.length > 0) {
}
c.removeChild(c.children[0]);
// Let the browser create the DOM elements from the html string.
this.intermediateContainer.innerHTML = r;
}
// Cut & paste them one after another.
while(this.intermediateContainer.children.length > 0) {
// Let the browser create the DOM elements from the html string.
this.intermediateContainer.innerHTML = r;
c.appendChild(this.intermediateContainer.children[0]);
// Cut & paste them one after another.
while(this.intermediateContainer.children.length > 0) {
c.appendChild(this.intermediateContainer.children[0]);
}
contentChanged = true;
}
contentChanged = true;
}

@@ -535,7 +541,7 @@

this._updateView(response);
document.title = response.title;
document.title = response.meta.title;
if(response.url) {
if(response.meta.url) {
this.absolutePath = response.url.replace(this.infix, "");
this.absolutePath = response.meta.url.replace(this.infix, "");

@@ -546,3 +552,3 @@ }

history.pushState({url: this.absolutePath}, response.title, this.absolutePath);
history.pushState({url: this.absolutePath}, response.meta.title, this.absolutePath);

@@ -573,3 +579,3 @@ } else {

var response = {};
var response = {meta: {}};

@@ -584,7 +590,7 @@ if(xhr.readyState === 4) {

response.title = "Parse Error";
response.meta.title = "Parse Error";
if(this.stderr !== null) {
response[this.stderr] = Stay.Error.UNPARSABLE;
response[this.stderr] = "<p>" + Stay.Error.UNPARSABLE + "</p>";

@@ -597,3 +603,3 @@ }

response.url = xhr.responseURL;
response.meta.url = xhr.responseURL;
this.eventReceive.status = xhr.status;

@@ -624,4 +630,4 @@ this.eventReceive.response = response;

Stay.Error = Object.freeze({
TIMEOUT: "<p>The server didn't respond in time. Please try again later!</p>",
UNPARSABLE: "<p>The received content could not be parsed.</p>"
TIMEOUT: "The server didn't respond in time. Please try again later!",
UNPARSABLE: "The received content could not be parsed."
});
{
"name": "Stay API",
"description": "Stay is a small but effective library for the creation of dynamic xhr-driven web applications.",
"version": "0.1.1",
"version": "0.1.2",
"url": "https://github.com/vanruesc/stay",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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