Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tightened json-px whitespace minification

  • Loading branch information...
commit ec022288add602eb2e8ef42284d3d679539e04a7 1 parent acbe8d6
@premasagar authored
Showing with 6,112 additions and 8 deletions.
  1. +29 −0 api-experiments/embed.html
  2. +6,078 −0 jquery.js
  3. +5 −8 tools/jsonpx.js
View
29 api-experiments/embed.html
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html lang=en>
+<head>
+ <meta charset=utf-8>
+ <title>Sqwidget data</title>
+</head>
+
+<body>
+ <h1>Script data demo</h1>
+
+ <h2>The data:</h2>
+ <pre><code id=report></code></pre>
+
+ <script
+ class = sqwidget
+ src = sqwidget.js
+ data-sqwidget-width = 300
+ data-sqwidget-height = 485
+ data-sqwidget-template = http://example.com/mywidget.html.js
+ data-sqwidget-version = 0.1
+ data-mywidget-foo = bar
+ ></script>
+ <!--
+ The script element's list of classes (via the class attribute) must include 'sqwidget' - everything else is optional.
+ The src attribute is optional. If present, it will load Sqwidget from a url, e.g. http://example.com/sqwidget.js
+ The script element may include any number of data-sqwidget- attributes, to be accessible by Sqwidget and from the template file, which is specified via an id or a url as the value of the data-sqwidget-template attribute.
+ -->
+</body>
+</html>
View
6,078 jquery.js
6,078 additions, 0 deletions not shown
View
13 tools/jsonpx.js
@@ -8,19 +8,16 @@ function jsonpx(html, callbackName, stripwhitespace){
txt = txt
.replace(new RegExp('>' + s + '+<', 'g'), '><')
.replace(new RegExp('(<style[^>]*>)' + s + '+(.)', 'g'), '$1$2')
- .replace(new RegExp('(<script[^>]*>)' + s + '+(.)', 'g'), '$1$2');
+ .replace(new RegExp('(<script[^>]*>)' + s + '+(.)', 'g'), '$1$2')
+ .replace(new RegExp(s + '+<\/script>' + s + '*', 'g'), '</script>')
+ .replace(new RegExp(s + '*<\/script>' + s + '+', 'g'), '</script>')
+ .replace(new RegExp(s + '+<\/style>' + s + '*', 'g'), '</style>')
+ .replace(new RegExp(s + '*<\/style>' + s + '+', 'g'), '</style>');
}
txt = txt
.replace(/'/g, "\\'")
.replace(/(?=\n)/g, '\\');
- if (stripwhitespace){
- txt = txt
- .replace(new RegExp('(;?)' + s + '+<\/script>' + s + '*', 'g'), '$1</script>')
- .replace(new RegExp('(;?)' + s + '*<\/script>' + s + '+', 'g'), '$1</script>')
- .replace(new RegExp('(}?)' + s + '+<\/style>' + s + '*', 'g'), '$1</style>')
- .replace(new RegExp('(}?)' + s + '*<\/style>' + s + '+', 'g'), '$1</style>');
- }
return txt;
}
Please sign in to comment.
Something went wrong with that request. Please try again.