diff --git a/dist/display.es6.js b/dist/display.es6.js index a41aeea..a40ca11 100644 --- a/dist/display.es6.js +++ b/dist/display.es6.js @@ -30,7 +30,14 @@ class DisplayJS { }, push); } } - xss(str) { + xss (str) { + var lt = //g, + ap = /'/g, + ic = /"/g; + return str.toString().replace(lt, "<").replace(gt, ">").replace(ap, "'").replace(ic, """); + } + xssURI(str) { return encodeURI(str); } target(callback) { diff --git a/dist/display.js b/dist/display.js index eed0a32..a79d57b 100644 --- a/dist/display.js +++ b/dist/display.js @@ -51,6 +51,15 @@ var DisplayJS = function () { }, { key: "xss", value: function xss(str) { + var lt = //g, + ap = /'/g, + ic = /"/g; + return str.toString().replace(lt, "<").replace(gt, ">").replace(ap, "'").replace(ic, """); + } + }, { + key: "xssURI", + value: function xssURI(str) { return encodeURI(str); } }, { diff --git a/dist/display.min.js b/dist/display.min.js index 2d4d3b6..9cb6078 100644 --- a/dist/display.min.js +++ b/dist/display.min.js @@ -1 +1 @@ -"use strict";function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n=200&&o.status<400){var e=o.responseText;r(e)}else console.error("DisplayJS error: The ajax request returned an error.")},o.onerror=function(){console.error("DisplayJS error: The ajax request returned an error.")},o.send(n)}},{key:"hasClass",value:function(e,t){return e[0].classList?e[0].classList.contains(t):!!e[0].className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},{key:"addClass",value:function(e,t){e[0].classList?e[0].classList.add(t):this.hasClass(e,t)||(e[0].className+=" "+t)}},{key:"removeClass",value:function(e,t){if(e[0].classList)e[0].classList.remove(t);else if(this.hasClass(e,t)){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e[0].className=e[0].className.replace(n," ")}}},{key:"toggleClass",value:function(e,t){this.hasClass(e,t)?this.removeClass(e,t):this.addClass(e,t)}},{key:"each",value:function(e,t){for(var n=0;n1||(r.style.opacity=n,requestAnimationFrame(e))}()}},{key:"extend",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=1;t=0;n--)t(e[n])}},{key:"reshape",value:function(e,t){for(var n=[],r=0;r0?e.slice(t,e.length):e.slice(0,e.length-t)}},{key:"isIn",value:function(e,t){return e.indexOf(t)>-1}},{key:"rmFromArray",value:function(e,t){var n=[];this.forIn(e,function(r){return t(r)||n.push(e[r]),n})}}]),DisplayJS}(),_DOM_DJS=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),t}(DisplayJS); \ No newline at end of file +"use strict";function _possibleConstructorReturn(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function _inherits(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,t){for(var n=0;n/g,">").replace(/'/g,"'").replace(/"/g,""")}},{key:"xssURI",value:function(e){return encodeURI(e)}},{key:"target",value:function(e){e=e||function(){this.var()};var t=function(){return document.addEventListener?function(e,t,n){e.addEventListener(t,n,!1)}:function(e,t,n){e.attachEvent("on"+t,n)}}(),n=this.obj;[].forEach.call(document.querySelectorAll("[target]"),function(r,i,o){t(o[i],"change",function(){var t=o[i].getAttribute("target");"checkbox"==this.type?n[t]=this.checked:n[t]=this.value,e()}),t(o[i],"keydown",function(){var t=o[i].getAttribute("target");"checkbox"==this.type?n[t]=this.checked:n[t]=this.value,e()}),t(o[i],"input",function(){var t=o[i].getAttribute("target");"checkbox"==this.type?n[t]=this.checked:n[t]=this.value,e()}),t(o[i],"paste",function(){var t=o[i].getAttribute("target");"checkbox"==this.type?n[t]=this.checked:n[t]=this.value,e()})})}},{key:"if",value:function _if(push){var _this2=this,if_push=function if_push(){for(var elements=document.querySelectorAll("[if]"),i=0;i=200&&o.status<400){var e=o.responseText;r(e)}else console.error("DisplayJS error: The ajax request returned an error.")},o.onerror=function(){console.error("DisplayJS error: The ajax request returned an error.")},o.send(n)}},{key:"hasClass",value:function(e,t){return e[0].classList?e[0].classList.contains(t):!!e[0].className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))}},{key:"addClass",value:function(e,t){e[0].classList?e[0].classList.add(t):this.hasClass(e,t)||(e[0].className+=" "+t)}},{key:"removeClass",value:function(e,t){if(e[0].classList)e[0].classList.remove(t);else if(this.hasClass(e,t)){var n=new RegExp("(\\s|^)"+t+"(\\s|$)");e[0].className=e[0].className.replace(n," ")}}},{key:"toggleClass",value:function(e,t){this.hasClass(e,t)?this.removeClass(e,t):this.addClass(e,t)}},{key:"each",value:function(e,t){for(var n=0;n1||(r.style.opacity=n,requestAnimationFrame(e))}()}},{key:"extend",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=1;t=0;n--)t(e[n])}},{key:"reshape",value:function(e,t){for(var n=[],r=0;r0?e.slice(t,e.length):e.slice(0,e.length-t)}},{key:"isIn",value:function(e,t){return e.indexOf(t)>-1}},{key:"rmFromArray",value:function(e,t){var n=[];this.forIn(e,function(r){return t(r)||n.push(e[r]),n})}}]),DisplayJS}(),_DOM_DJS=function(e){function t(){return _classCallCheck(this,t),_possibleConstructorReturn(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return _inherits(t,e),t}(DisplayJS); \ No newline at end of file diff --git a/package.json b/package.json index 14054c6..b1354a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "display.js", - "version": "v0.2.0", + "version": "v0.2.1", "description": "A simple framework for building ambitious UI, without thinking about how the text will be displayed.", "main": "dist/display.min.js", "directories": { diff --git a/src/display.js b/src/display.js index a41aeea..16cc3ad 100644 --- a/src/display.js +++ b/src/display.js @@ -30,7 +30,14 @@ class DisplayJS { }, push); } } - xss(str) { + xss (str) { + var lt = //g, + ap = /'/g, + ic = /"/g; + return str.toString().replace(lt, "<").replace(gt, ">").replace(ap, "'").replace(ic, """); + } + xssURI(str) { return encodeURI(str); } target(callback) {