diff --git a/.gitignore b/.gitignore index 61bd80c..893ac04 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,8 @@ node_modules bower_components -dist \ No newline at end of file +build + +.idea + +COMMIT_MSG \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bee22b7 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,5 @@ +language: node_js +node_js: + - "4.1" +before_install: npm install -g grunt-cli +install: npm install && bower install \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 067efc4..9c955f9 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -11,31 +11,29 @@ module.exports = function (grunt) { ' Licensed <%= pkg.license %> */\n', // Task configuration copy: { - dist: { + mock: { expand: true, cwd: 'dist/', - src: '**', + src: ['jdbcsniffer.js','jdbcsniffer.min.js'], dest: 'mock/' - }, - }, - concat: { - options: { - banner: '<%= banner %>', - stripBanners: true - }, - dist: { - src: ['src/jdbcsniffer.js'], - dest: 'dist/jdbcsniffer.js' } }, includereplace: { dist: { options: { prefix: '//@@', - suffix: '' + suffix: '', + processIncludeContents: function(includeContents, localVars, filePath) { + return filePath.endsWith('.js') ? includeContents : + includeContents.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, " "); + } }, - src: 'dist/jdbcsniffer.js', + src: 'src/jdbcsniffer.js', dest: 'dist/jdbcsniffer.js' + }, + iframe: { + src: 'src/jdbcsniffer.iframe.html', + dest: 'build/jdbcsniffer.iframe.html' } }, uglify: { @@ -79,7 +77,7 @@ module.exports = function (grunt) { }, dist: { files: { - "dist/jdbcsniffer.css": "src/jdbcsniffer.less" // destination file and source file + "build/jdbcsniffer.css": "src/jdbcsniffer.less" } } }, @@ -90,29 +88,41 @@ module.exports = function (grunt) { dist: { options: { removeComments: true, - collapseWhitespace: true + collapseWhitespace: true, + minifyCSS: true, + minifyJS: true }, files: { - 'dist/jdbcsniffer.html': 'src/jdbcsniffer.html', + 'build/jdbcsniffer.iframe.html': 'build/jdbcsniffer.iframe.html' } } }, + imageEmbed: { + dist: { + src: [ "bower_components/bootstrap/dist/css/bootstrap.min.css" ], + dest: "build/bootstrap.embedded.css", + options: { + deleteAfterEncoding : false, + preEncodeCallback: function () { return true; } + } + } + }, watch: { gruntfile: { files: '<%= jshint.gruntfile.src %>', - tasks: ['jshint:gruntfile'] + tasks: ['jshint:gruntfile', 'includereplace:iframe', 'htmlmin', 'less', 'jshint', 'includereplace:dist', 'uglify', 'copy'] }, htmlmin: { files: 'src/*.html', - tasks: ['htmlmin:dist','jshint:dist','concat:dist','includereplace:dist','uglify:dist','copy:dist'] + tasks: ['includereplace:iframe','htmlmin:dist','jshint:dist','includereplace:dist','uglify:dist','copy:mock'] }, src: { files: 'src/*.js', - tasks: ['jshint:dist','concat:dist','includereplace:dist','uglify:dist','copy:dist'] + tasks: ['jshint:dist','includereplace:dist','uglify:dist','copy:mock'] }, styles: { - files: ['src/*.less'], // which files to watch - tasks: ['less:dist','copy:dist'/*,'replace:dist'*/], + files: ['src/*.less'], + tasks: ['less:dist','copy:mock'], options: { nospawn: true } @@ -121,17 +131,18 @@ module.exports = function (grunt) { }); // These plugins provide necessary tasks - grunt.loadNpmTasks('grunt-contrib-concat'); + grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-qunit'); grunt.loadNpmTasks('grunt-contrib-jshint'); grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-contrib-less'); grunt.loadNpmTasks('grunt-include-replace'); grunt.loadNpmTasks('grunt-contrib-htmlmin'); - grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-notify'); + grunt.loadNpmTasks("grunt-image-embed"); // Default task - grunt.registerTask('default', ['concat', 'htmlmin', 'less', 'jshint', /*'qunit',*/ 'includereplace', 'uglify', 'copy']); + grunt.registerTask('default', ['imageEmbed', 'includereplace:iframe', 'htmlmin', 'less', 'jshint', 'includereplace:dist', 'uglify', 'copy']); + grunt.registerTask('travis', ['default']); }; diff --git a/README.md b/README.md index 1123820..12ff04f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,9 @@ -# jdbc-sniffer-ui -UI for JDBC Sniffer +[![Build Status](https://travis-ci.org/sniffy/sniffy-ui.svg?branch=develop)](https://travis-ci.org/sniffy/sniffy-ui) +[![Dependency Status](https://david-dm.org/sniffy/sniffy-ui.svg)](https://david-dm.org/sniffy/sniffy-ui) +[![devDependency Status](https://david-dm.org/sniffyii/dev-status.svg)](https://david-dm.org/sniffy/sniffy-ui#info=devDependencies) + +# sniffy-ui +Sniffy UI ## Building @@ -21,4 +25,4 @@ grunt watch node index.js ``` -Now open [http://localhost:3000/dist/mock.html](http://localhost:3000/dist/mock.html) in your browser and have fun! \ No newline at end of file +Now open [http://localhost:3000/mock/mock.html](http://localhost:3000/mock/mock.html) in your browser and have fun! \ No newline at end of file diff --git a/bower.json b/bower.json index fec1186..7ef6ad7 100755 --- a/bower.json +++ b/bower.json @@ -1,13 +1,18 @@ { - "name": "jdbc-sniffer-ui", - "version": "1.1.0", - "homepage": "https://github.com/bedrin/jdbc-sniffer-ui", + "name": "sniffy", + "homepage": "http://sniffy.io", + "repository": { + "type": "git", + "url": "git@github.com:sniffy/sniffy-ui.git" + }, "authors": [ "bedrin " ], - "description": "UI for JDBC Sniffer", - "main": "jdbcsniffer.js", + "description": "Sniffy - next generation profiler", + "keywords": "profiler, monitoring, jdbc", + "main": "./dist/jdbcsniffer.js", "license": "BSD-3-Clause", + "moduleType": "globals", "ignore": [ "**/.*", "node_modules", @@ -17,6 +22,8 @@ ], "dependencies": { "minified": "~2015.1.1", - "bootstrap": "~3.3.5" + "bootstrap": "~3.3.5", + "highlightjs": "~8.9.1", + "clipboard": "~1.5.5" } } diff --git a/dist/jdbcsniffer.iframe.html b/dist/jdbcsniffer.iframe.html new file mode 100644 index 0000000..ff62fe0 --- /dev/null +++ b/dist/jdbcsniffer.iframe.html @@ -0,0 +1,5 @@ +JDBC Sniffer

Executed Queries

QueryTime
\ No newline at end of file diff --git a/dist/jdbcsniffer.js b/dist/jdbcsniffer.js new file mode 100644 index 0000000..e3c800b --- /dev/null +++ b/dist/jdbcsniffer.js @@ -0,0 +1,209 @@ +;(function(){ + + /*jshint unused:false*/ + + // require/define basic support + + var defs = {}; + + function require(name) { + return defs[name]; + } + + function define(name, f) { + defs[name] = defs[name] || f(require); + } + + // include libraries: minified.js + + /^u/.test(typeof define)&&function(a){var b=this.require=function(b){return a[b]};this.define=function(c,d){a[c]=a[c]||d(b)}}({}),define("minified",function(){function a(a){return a.substr(0,3)}function b(a){return a!=Fa?""+a:""}function c(a){return"string"==typeof a}function d(a){return!!a&&"object"==typeof a}function e(a){return a&&a.nodeType}function f(a){return"number"==typeof a}function g(a){return d(a)&&!!a.getDay}function h(a){return!0===a||!1===a}function i(a){var b=typeof a;return"object"==b?!(!a||!a.getDay):"string"==b||"number"==b||h(a)}function j(a){return a}function k(a){return a+1}function l(a,c,d){return b(a).replace(c,d!=Fa?d:"")}function m(a){return l(a,/[\\\[\]\/{}()*+?.$|^-]/g,"\\$&")}function n(a){return l(a,/^\s+|\s+$/g)}function o(a,b,c){for(var d in a)a.hasOwnProperty(d)&&b.call(c||a,d,a[d]);return a}function p(a,b,c){if(a)for(var d=0;db?Math.max(a.length+b,0):Math.min(a.length,b)}function E(a,b,c,d){b=C(b),d=D(a,d,a.length);for(var e=D(a,c,0);d>e;e++)if((c=b.call(a,a[e],e))!=Fa)return c}function F(a,b,c,d){b=C(b),d=D(a,d,-1);for(var e=D(a,c,a.length-1);e>d;e--)if((c=b.call(a,a[e],e))!=Fa)return c}function G(a,b,c){var d=[];if(a)for(c=D(a,c,a.length),b=D(a,b,0);c>b;b++)d.push(a[b]);return d}function H(a){return v(a,j)}function I(a){return function(){return new va(O(a,arguments))}}function J(a){var b={};return q(a,function(a){return b[a]?!1:b[a]=1})}function K(a,b){var c=z(b,1);return q(a,function(a){var b=c[a];return c[a]=0,b})}function L(a,b){for(var c=0;cb?"-":"",d=(c?-b:b).toFixed(0);d.lengthf)return-W(a,c,b);if(b={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5}[a])return f/b;for(b=a.charAt(0).toUpperCase()+a.substr(1),a=Math.floor(f/{fullYear:31536e6,month:2628e6,date:864e5}[a]-2),d=U(new Date(d),b,a),f=a;1.2*a+4>f;f++)if(+U(d,b,1)>e)return f}function X(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}function Y(a){return l(a,/[\x00-\x1f'"\u2028\u2029]/g,X)}function Z(a,b){return a.split(b)}function $(a,b){function c(a,c){var d=[];return e.call(c||a,a,function(a,b){fa(a)?p(a,function(a,c){b.call(a,a,c)}):o(a,function(a,c){b.call(c,a,c)})},b||j,function(){N(d.push,d,arguments)},wa),d.join("")}if(Ma[a])return Ma[a];var d="with(_.isObject(obj)?obj:{}){"+v(Z(a,/{{|}}}?/g),function(a,b){var c,d=n(a),e=l(d,/^{/),d=d==e?"esc(":"";return b%2?(c=/^each\b(\s+([\w_]+(\s*,\s*[\w_]+)?)\s*:)?(.*)/.exec(e))?"each("+(n(c[4])?c[4]:"this")+", function("+c[2]+"){":(c=/^if\b(.*)/.exec(e))?"if("+c[1]+"){":(c=/^else\b\s*(if\b(.*))?/.exec(e))?"}else "+(c[1]?"if("+c[2]+")":"")+"{":(c=/^\/(if)?/.exec(e))?c[1]?"}\n":"});\n":(c=/^(var\s.*)/.exec(e))?c[1]+";":(c=/^#(.*)/.exec(e))?c[1]:(c=/(.*)::\s*(.*)/.exec(e))?"print("+d+'_.formatValue("'+Y(c[2])+'",'+(n(c[1])?c[1]:"this")+(d&&")")+"));\n":"print("+d+(n(e)?e:"this")+(d&&")")+");\n":a?'print("'+Y(a)+'");\n':void 0}).join("")+"}",e=Function("obj","each","esc","print","_",d);return 99'"&]/g,function(a){return"&#"+a.charCodeAt(0)+";"})}function aa(a,b){return $(a,_)(b)}function ba(a){return function(b,c){return new va(a(this,b,c))}}function ca(a){return function(b,c,d){return a(this,b,c,d)}}function da(a){return function(b,c,d){return new va(a(b,c,d))}}function ea(a){return"function"==typeof a&&!a.item}function fa(a){return a&&a.length!=Fa&&!c(a)&&!e(a)&&!ea(a)&&a!==ya}function ga(a){return parseFloat(l(a,/^[^\d-]+/))}function ha(a){return a.Nia=a.Nia||++Ba}function ia(a,b){var c,d=[],e={};return sa(a,function(a){sa(b(a),function(a){e[c=ha(a)]||(d.push(a),e[c]=!0)})}),d}function ja(a,b){var c={$position:"absolute",$visibility:"hidden",$display:"block",$height:Fa},d=a.get(c),c=a.set(c).get("clientHeight");return a.set(d),c*b+"px"}function ka(a){Ca?Ca.push(a):setTimeout(a,0)}function la(a,b,c){return pa(a,b,c)[0]}function ma(a,b,c){return a=oa(document.createElement(a)),fa(b)||b!=Fa&&!d(b)?a.add(b):a.set(b).add(c)}function na(a){return r(sa,a,function(a){return fa(a)?na(a):(e(a)&&(a=a.cloneNode(!0),a.removeAttribute&&a.removeAttribute("id")),a)})}function oa(a,b,c){return ea(a)?ka(a):new va(pa(a,b,c))}function pa(a,b,d){function f(a){return fa(a)?r(sa,a,f):a}function g(a){return q(r(sa,a,f),function(a){for(;a=a.parentNode;)if(a==b[0]||d)return a==b[0]})}return b?1!=(b=pa(b)).length?ia(b,function(b){return pa(a,b,d)}):c(a)?1!=e(b[0])?[]:d?g(b[0].querySelectorAll(a)):b[0].querySelectorAll(a):g(a):c(a)?document.querySelectorAll(a):r(sa,a,f)}function qa(a,b){function d(a,b){var c=RegExp("(^|\\s+)"+a+"(?=$|\\s)","i");return function(d){return a?c.test(d[b]):!0}}var g,h,i={},j=i;return ea(a)?a:f(a)?function(b,c){return c==a}:!a||"*"==a||c(a)&&(j=/^([\w-]*)\.?([\w-]*)$/.exec(a))?(g=d(j[1],"tagName"),h=d(j[2],"className"),function(a){return 1==e(a)&&g(a)&&h(a)}):b?function(c){return oa(a,b).find(c)!=Fa}:(oa(a).each(function(a){i[ha(a)]=!0}),function(a){return i[ha(a)]})}function ra(a){var b=qa(a);return function(a){return b(a)?Fa:!0}}function sa(a,b){return fa(a)?p(a,b):a!=Fa&&b(a,0),a}function ta(){this.state=null,this.values=[],this.parent=null}function ua(){var a,b,c=[],e=arguments,f=e.length,g=0,h=0,i=new ta;return i.errHandled=function(){h++,i.parent&&i.parent.errHandled()},a=i.fire=function(a,b){return null==i.state&&null!=a&&(i.state=!!a,i.values=fa(b)?b:[b],setTimeout(function(){p(c,function(a){a()})},0)),i},p(e,function j(b,c){try{b.then?b.then(function(b){(d(b)||ea(b))&&ea(b.then)?j(b,c):(i.values[c]=H(arguments),++g==f&&a(!0,2>f?i.values[c]:i.values))},function(){i.values[c]=H(arguments),a(!1,2>f?i.values[c]:[i.values[c][0],i.values,c])}):b(function(){a(!0,H(arguments))},function(){a(!1,H(arguments))})}catch(e){a(!1,[e,i.values,c])}}),i.stop=function(){return p(e,function(a){a.stop&&a.stop()}),i.stop0&&N(i.stop0)},b=i.then=function(a,b){function e(){try{var c=i.state?a:b;ea(c)?function g(a){try{var b,c=0;if((d(a)||ea(a))&&ea(b=a.then)){if(a===f)throw new TypeError;b.call(a,function(a){c++||g(a)},function(a){c++||f.fire(!1,[a])}),f.stop0=a.stop}else f.fire(!0,[a])}catch(e){if(!c++&&(f.fire(!1,[e]),!h))throw e}}(N(c,xa,i.values)):f.fire(i.state,i.values)}catch(e){if(f.fire(!1,[e]),!h)throw e}}var f=ua();return ea(b)&&i.errHandled(),f.stop0=i.stop,f.parent=i,null!=i.state?setTimeout(e,0):c.push(e),f},i.always=function(a){return b(a,a)},i.error=function(a){return b(0,a)},i}function va(a,b){var c,d,e,f,g,h=0;if(a)for(c=0,d=a.length;d>c;c++)if(e=a[c],b&&fa(e))for(f=0,g=e.length;g>f;f++)this[h++]=e[f];else this[h++]=e;else this[h++]=b;this.length=h,this._=!0}function wa(){return new va(arguments,!0)}var xa,ya=window,za={},Aa={},Ba=1,Ca=/^[ic]/.test(document.readyState)?Fa:[],Da={},Ea=0,Fa=null,Ga=Z("January,February,March,April,May,June,July,August,September,October,November,December",/,/g),Ha=v(Ga,a),Ia=Z("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",/,/g),Ja=v(Ia,a),Ka={y:["FullYear",j],Y:["FullYear",function(a){return a%100}],M:["Month",k],n:["Month",Ha],N:["Month",Ga],d:["Date",j],m:["Minutes",j],H:["Hours",j],h:["Hours",function(a){return a%12||12}],k:["Hours",k],K:["Hours",function(a){return a%12}],s:["Seconds",j],S:["Milliseconds",j],a:["Hours",Z("am,am,am,am,am,am,am,am,am,am,am,am,pm,pm,pm,pm,pm,pm,pm,pm,pm,pm,pm,pm",/,/g)],w:["Day",Ja],W:["Day",Ia],z:["TimezoneOffset",function(a,b,c){return c?c:(b=0>a?-a:a,(a>0?"-":"+")+Q(2,Math.floor(b/60))+Q(2,b%60))}]},La={y:0,Y:[0,-2e3],M:[1,1],n:[1,Ha],N:[1,Ga],d:2,m:4,H:3,h:3,K:[3,1],k:[3,1],s:5,S:6,a:[3,Z("am,pm",/,/g)]},Ma={},Na=[];return A({each:ca(p),filter:ba(q),collect:ba(s),map:ba(v),toObject:ca(z),equals:ca(M),sub:ba(G),reverse:ca(y),find:ca(E),findLast:ca(F),startsWith:ca(w),endsWith:ca(x),contains:ca(L),call:ba(O),array:ca(H),unite:ca(I),merge:ca(B),uniq:ba(J),intersection:ba(K),join:function(a){return v(this,j).join(a)},reduce:function(a,b){return p(this,function(c,d){b=a.call(this,b,c,d)}),b},sort:function(a){return new va(v(this,j).sort(a))},remove:function(){sa(this,function(a){a.parentNode.removeChild(a)})},text:function(){return r(sa,this,function(a){return a.textContent}).join("")},trav:function(a,b,c){var d=f(b),e=qa(d?Fa:b),g=d?b:c;return new va(ia(this,function(b){for(var c=[];(b=b[a])&&c.length!=g;)e(b)&&c.push(b);return c}))},next:function(a,b){return this.trav("nextSibling",a,b||1)},up:function(a,b){return this.trav("parentNode",a,b||1)},select:function(a,b){return oa(a,this,b)},is:function(a){return!this.find(ra(a))},only:function(a){return new va(q(this,qa(a)))},not:function(a){return new va(q(this,ra(a)))},get:function(a,b){var d,e,f,g,h=this,i=h[0];return i?c(a)?(d=/^(\W*)(.*)/.exec(l(a,/^%/,"@data-")),e=d[1],f=Aa[e]?Aa[e](this,d[2]):"$"==a?h.get("className"):"$$"==a?h.get("@style"):"$$slide"==a?h.get("$height"):"$$fade"==a||"$$show"==a?"hidden"==h.get("$visibility")||"none"==h.get("$display")?0:"$$fade"==a?isNaN(h.get("$opacity",!0))?1:h.get("$opacity",!0):1:"$"==e?ya.getComputedStyle(i,Fa).getPropertyValue(l(d[2],/[A-Z]/g,function(a){return"-"+a.toLowerCase()})):"@"==e?i.getAttribute(d[2]):i[d[2]],b?ga(f):f):(g={},(fa(a)?sa:o)(a,function(a){g[a]=h.get(a,b)}),g):void 0},set:function(a,b){var d,e,f=this;return b!==xa?(d=/^(\W*)(.*)/.exec(l(l(a,/^\$float$/,"cssFloat"),/^%/,"@data-")),e=d[1],za[e]?za[e](this,d[2],b):"$$fade"==a?this.set({$visibility:b?"visible":"hidden",$opacity:b}):"$$slide"==a?f.set({$visibility:b?"visible":"hidden",$overflow:"hidden",$height:/px/.test(b)?b:function(a,c,d){return ja(oa(d),b)}}):"$$show"==a?b?f.set({$visibility:b?"visible":"hidden",$display:""}).set({$display:function(a){return"none"==a?"block":a}}):f.set({$display:"none"}):"$$"==a?f.set("@style",b):sa(this,function(c,f){var g=ea(b)?b(oa(c).get(a),f,c):b;"$"==e?d[2]?c.style[d[2]]=g:sa(g&&g.split(/\s+/),function(a){var b=l(a,/^[+-]/),d=c.className||"",e=l(d,RegExp("(^|\\s+)"+b+"(?=$|\\s)"));(/^\+/.test(a)||b==a&&d==e)&&(e+=" "+b),c.className=n(e)}):"$$scrollX"==a?c.scroll(g,oa(c).get("$$scrollY")):"$$scrollY"==a?c.scroll(oa(c).get("$$scrollX"),g):"@"==e?g==Fa?c.removeAttribute(d[2]):c.setAttribute(d[2],g):c[d[2]]=g})):c(a)||ea(a)?f.set("$",a):o(a,function(a,b){f.set(a,b)}),f},show:function(){return this.set("$$show",1)},hide:function(){return this.set("$$show",0)},add:function(a,b){return this.each(function(c,d){function f(a){fa(a)?sa(a,f):ea(a)?f(a(c,d)):a!=Fa&&(a=e(a)?a:document.createTextNode(a),g?g.parentNode.insertBefore(a,g.nextSibling):b?b(a,c,c.parentNode):c.appendChild(a),g=a)}var g;f(d&&!ea(a)?na(a):a)})},fill:function(a){return this.each(function(a){oa(a.childNodes).remove()}).add(a)},addAfter:function(a){return this.add(a,function(a,b,c){c.insertBefore(a,b.nextSibling)})},addBefore:function(a){return this.add(a,function(a,b,c){c.insertBefore(a,b)})},addFront:function(a){return this.add(a,function(a,b){b.insertBefore(a,b.firstChild)})},replace:function(a){return this.add(a,function(a,b,c){c.replaceChild(a,b)})},clone:ba(na),animate:function(a,b,c){var d,e=ua(),f=this,g=r(sa,this,function(b,d){var e,f=oa(b),g={};return o(e=f.get(a),function(c,e){var h=a[c];g[c]=ea(h)?h(e,d,b):"$$slide"==c?ja(f,h):h}),f.dial(e,g,c)}),h=b||500;return e.stop0=function(){return e.fire(!1),d()},d=oa.loop(function(a){O(g,[a/h]),a>=h&&(d(),e.fire(!0,[f]))}),e},dial:function(a,c,d){function e(a,b){return/^#/.test(a)?parseInt(6=d?g:d>=1?i:/^#|rgb\(/.test(i)?"rgb("+Math.round(h(e(g,j),e(i,j++),d))+","+Math.round(h(e(g,j),e(i,j++),d))+","+Math.round(h(e(g,j),e(i,j++),d))+")":l(i,/-?[\d.]+/,b(h(ga(g),ga(i),d))))})}},toggle:function(a,b,c,d){var e,f,g=this,h=!1;return b?(g.set(a),function(i){i!==h&&(f=(h=!0===i||!1===i?i:!h)?b:a,c?(e=g.animate(f,e?e.stop():c,d)).then(function(){e=Fa}):g.set(f))}):g.toggle(l(a,/\b(?=\w)/g,"-"),l(a,/\b(?=\w)/g,"+"))},values:function(a){var c=a||{};return this.each(function(a){var d=a.name||a.id,e=b(a.value);if(/form/i.test(a.tagName))for(d=0;dd;d++)a.call(this,new va(Fa,this[d]),d);else oa(a,this).per(b);return this},ht:function(a,b){var c=2f.status?h.fire(!0,[f.responseText,f]):h.fire(!1,[f.status,f.responseText,f]))},f.send(d)}catch(j){g||h.fire(!1,[0,Fa,b(j)])}return h},toJSON:JSON.stringify,parseJSON:JSON.parse,ready:ka,loop:function(a){function b(a){o(Da,function(b,c){c(a)}),Ea&&g(b)}function c(){return Da[f]&&(delete Da[f],Ea--),e}var d,e=0,f=Ba++,g=ya.requestAnimationFrame||function(a){setTimeout(function(){a(+new Date)},33)};return Da[f]=function(b){d=d||b,a(e=b-d,c)},Ea++||g(b),c},off:function(a){O(a.M),a.M=Fa},setCookie:function(a,b,c,e){document.cookie=a+"="+(e?b:escape(b))+(c?"; expires="+(d(c)?c:new Date(+new Date+864e5*c)).toUTCString():"")},getCookie:function(a,b){var c,d=(c=RegExp("(^|;)\\s*"+a+"=([^;]*)").exec(document.cookie))&&c[2];return b?d:d&&unescape(d)},wait:function(a,b){var c=ua(),d=setTimeout(function(){c.fire(!0,b)},a);return c.stop0=function(){c.fire(!1),clearTimeout(d)},c}},oa),A({filter:da(q),collect:da(s),map:da(v),sub:da(G),reverse:y,each:p,toObject:z,find:E,findLast:F,contains:L,startsWith:w,endsWith:x,equals:M,call:da(O),array:H,unite:I,merge:B,uniq:da(J),intersection:da(K),keys:da(u),values:da(function(a,b){var c=[];return b?p(b,function(b){c.push(a[b])}):o(a,function(a,b){c.push(b)}),c}),copyObj:A,extend:function(a){return B(G(arguments,1),a)},range:function(a,b){for(var c=[],d=b==Fa?a:b,e=b!=Fa?a:0;d>e;e++)c.push(e);return new va(c)},bind:P,partial:function(a,b,c){return P(a,this,b,c)},eachObj:o,mapObj:function(a,b,c){var d={};return o(a,function(e,f){d[e]=b.call(c||a,e,f)}),d},filterObj:function(a,b,c){var d={};return o(a,function(e,f){b.call(c||a,e,f)&&(d[e]=f)}),d},isList:fa,isFunction:ea,isObject:d,isNumber:f,isBool:h,isDate:g,isValue:i,isString:c,toString:b,dateClone:T,dateAdd:V,dateDiff:W,dateMidnight:function(a){return a=a||new Date,new Date(a.getFullYear(),a.getMonth(),a.getDate())},pad:Q,formatValue:function(a,d){var e,h,i=l(a,/^\?/);return g(d)?((h=/^\[(([+-])(\d\d)(\d\d))\]\s*(.*)/.exec(i))&&(e=h[1],d=V(d,"minutes",S(h,2,d)),i=h[5]),l(i,/(\w)(\1*)(?:\[([^\]]+)\])?/g,function(a,b,f,g){return(b=Ka[b])&&(a=d["get"+b[0]](),g=g&&g.split(","),a=fa(b[1])?(g||b[1])[a]:b[1](a,g,e),a==Fa||c(a)||(a=Q(f.length+1,a))),a})):E(i.split(/\s*\|\s*/),function(a){var c,e;if(c=/^([<>]?)(=?)([^:]*?)\s*:\s*(.*)$/.exec(a)){if(a=d,e=+c[3],(isNaN(e)||!f(a))&&(a=a==Fa?"null":b(a),e=c[3]),c[1]){if(!c[2]&&a==e||"<"==c[1]&&a>e||">"==c[1]&&e>a)return Fa}else if(a!=e)return Fa;c=c[4]}else c=a;return f(d)?c.replace(/[0#](.*[0#])?/,function(a){var b,c=/^([^.]+)(\.)([^.]+)$/.exec(a)||/^([^,]+)(,)([^,]+)$/.exec(a),e=0>d?"-":"",f=/(\d+)(\.(\d+))?/.exec((e?-d:d).toFixed(c?c[3].length:0));return a=c?c[1]:a,b=c?R(c[3],l(f[3],/0+$/),!0):"",(e?"-":"")+("#"==a?f[1]:R(a,f[1]))+(b.length?c[2]:"")+b}):c})},parseDate:function(a,b){var c,d,e,f,g,h,i,j,k,o={},p=1,q=l(a,/^\?/);if(q!=a&&!n(b))return Fa;if((e=/^\[([+-])(\d\d)(\d\d)\]\s*(.*)/.exec(q))&&(c=e,q=e[4]),!(e=RegExp(q.replace(/(.)(\1*)(?:\[([^\]]*)\])?/g,function(a,b,c,e){return/[dmhkyhs]/i.test(b)?(o[p++]=b,a=c.length+1,"(\\d"+(2>a?"+":"{1,"+a+"}")+")"):"z"==b?(d=p,p+=3,"([+-])(\\d\\d)(\\d\\d)"):/[Nna]/.test(b)?(o[p++]=[b,e&&e.split(",")],"([a-zA-Z\\u0080-\\u1fff]+)"):/w/i.test(b)?"[a-zA-Z\\u0080-\\u1fff]+":/\s/.test(b)?"\\s+":m(a)})).exec(b)))return xa;for(q=[0,0,0,0,0,0,0],f=1;p>f;f++)if(g=e[f],h=o[f],fa(h)){if(i=h[0],j=La[i],k=j[0],h=E(h[1]||j[1],function(a,b){return w(g.toLowerCase(),a.toLowerCase())?b:void 0}),h==Fa)return xa;q[k]="a"==i?q[k]+12*h:h}else h&&(i=parseFloat(g),j=La[h],fa(j)?q[j[0]]+=i-j[1]:q[j]+=i);return q=new Date(q[0],q[1],q[2],q[3],q[4],q[5],q[6]),V(q,"minutes",-S(c,1,q)-S(e,d,q))},parseNumber:function(a,b){var c=l(a,/^\?/);return c==a||n(b)?(c=/(^|[^0#.,])(,|[0#.]*,[0#]+|[0#]+\.[0#]+\.[0#.,]*)($|[^0#.,])/.test(c)?",":".",c=parseFloat(l(l(l(b,","==c?/\./g:/,/g),c,"."),/^[^\d-]*(-?\d)/,"$1")),isNaN(c)?xa:c):Fa},trim:n,isEmpty:function(a,b){return a==Fa||!a.length||b&&/^\s*$/.test(a)},escapeRegExp:m,escapeHtml:_,format:function(a,b,c){return $(a,c)(b)},template:$,formatHtml:aa,promise:ua},wa),document.addEventListener("DOMContentLoaded",function(){O(Ca),Ca=Fa},!1),{HTML:function(){var a=ma("div");return wa(N(a.ht,a,arguments)[0].childNodes)},_:wa,$:oa,$$:la,EE:ma,M:va,getter:Aa,setter:za}}); + + var MINI = require('minified'); + var $ = MINI.$, EE = MINI.EE, HTML = MINI.HTML; + + // register jdbcSniffer in global scope + + window.jdbcSniffer = { + numberOfSqlQueries : 0 + }; + + var ajaxRequests = []; + var loadQueries = function(url, requestId) { + ajaxRequests.push({"url":url,"requestId":requestId}); + }; + + var incrementQueryCounter = function(numQueries) { + // increment global counter + window.jdbcSniffer.numberOfSqlQueries += numQueries; + }; + + // setup sniffer UI on dom ready + + $(function(){ + + var fixZIndex = function() { + $('body *').filter(function(el, index){ + return $(el).get('$zIndex') === '2147483647' && $(el).get('$') !== 'jdbc-sniffer-query-count'; + }).set('$zIndex','2147483646'); + }; + fixZIndex(); + window.setTimeout(fixZIndex, 10); + window.setTimeout(fixZIndex, 100); + window.setTimeout(fixZIndex, 1000); + window.setTimeout(fixZIndex, 2000); + + var snifferHeaderElement = $('#jdbc-sniffer-header'); + var requestId = snifferHeaderElement.get('%request-id'); + var snifferScriptSrc = snifferHeaderElement.get('@src'); + var baseUrl = snifferScriptSrc.substring(0, snifferScriptSrc.lastIndexOf('/') + 1); + + var snifferElement = $('#jdbc-sniffer'); + var sqlQueries = snifferElement.get('%sql-queries'); + + // inject stylesheet + $('head').add(EE('style', '.jdbc-sniffer-iframe{border:0;margin:auto;width:100%;height:95%;left:0;right:0;top:0;bottom:0;position:fixed;z-index:2147483647}@media (min-width:768px){.jdbc-sniffer-iframe{width:750px}}@media (min-width:992px){.jdbc-sniffer-iframe{width:970px}}@media (min-width:1200px){.jdbc-sniffer-iframe{width:1170px}}.jdbc-sniffer-query-count{color:red;text-align:center;font-weight:bold;position:fixed;right:20px;bottom:20px;width:24px;height:24px;background-size:100%;z-index:9999999990;opacity:1;font-size:16px !important;line-height:normal !important;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADAklEQVRIibWWzWscdRzGP59hCEGWEEIstZYQQntICbnqxYuI4E0EPcQ/QQ9eJd7s4lEEUfCil+5JL8WLJ98u6qmEkMUXqgQsNYRYllJKCPN4mNmd2aTZouBv2d1nZn6/5/v6fHcFGOxdB10GNoCNwFXCKuSiupRkAZxTCpICrCLHkJFwGDgQ94FfgT1gl3Bn69o2Dvb6a8i7wAvAcqCQdgXw3+FKOAK+S/J2ibwBbI0JTx/yFB5fzMAFYRl5Rb1dAkXX3RBE7IQxHVFqsm6I52BhvpyKT3CK7uxy4vLZ3DwKFy3fKc/OWWk2pXnNxAkFUJFuMrvRnv1sTraXM7BIAXyPHpzNXxvnNBYUdTbGO8DXAtwYXr8sPg88B2wCVwJLj0rvjHUI/ELYQb4Fvtla377rYNhfS3L4+rV3Rt3dg2G/l3DRWhs9pSR1zRIq5RgYEY6Qg6317fvd8zeG/UVh2cGw/wHwMuGHmB/F3YQ/lFGSh8ix8QSppitkAZTAXMK8spiwhmwIz0CeBT8vSUBXkBXxNQBrspFwL/AAeUA4QaqQohZfSuITSk+zkLCgtppCEooSrcZOpS1oEVgUF22aoyOVutQJ2FQntMKcbK7FWkITuh3LnVym86yma1xoGGdi6jExKU7bKZnyeMr7tN+PxTAqgfeAv0heRTeSLE+8bFg7UbdpoXtzgquQA3UX+CLJZyVwAnwEfpKwhF4CrggrwFPAEtID5gllasGfBB4KI+Ao+CdhX/lNvdu0bqWWJeRN8GnkK+En4NbW+vYt/sMa7PVBFjEvgi8BvzsY9t8H3mpGdYXuQ24b9pFDwt/gCDkmnDRcZcic2kvyJHihbvOsES7VI0iAD8uJ+TqHhbAaXG1SQWwfT+7RGeu2Az6d35E05eoI43/oImsDx2OTCfWYjQ1uzHVw3UVjS4/DVAXwKeRL5F7trnVamvdEaGM8FqKeg6kCRyQ3gY8FGAz7BeEysAnZRK9St+kFYAno0aSzHl0h9QC8b012AOyjPwM7wM74b8s/Owp6BPc7ajsAAAAASUVORK5CYII=)}.jdbc-sniffer-query-count:hover{cursor:pointer}')); + + // create main GUI + + var iframe = EE('iframe', {'$display' : 'none', 'className' : 'jdbc-sniffer-iframe', '@scrolling' : 'no'}); + $('body').add(iframe); + var toggle = iframe.toggle({'$display': 'none'}, {'$display': 'block'}); + + // append toolbar + var queryCounterDiv = EE('div', { 'className' : 'jdbc-sniffer-query-count' }, sqlQueries); + queryCounterDiv.on('click', toggle); + $('body').add(queryCounterDiv); + + // create iframe GUI + + var iframeHtml = 'JDBC Sniffer

Executed Queries

QueryTime
'; + var iframeDocument = iframe.get('contentWindow').document; + iframeDocument.open(); + iframeDocument.write(iframeHtml); + iframeDocument.close(); + + var statementsTableBody = $(iframeDocument.getElementById('jdbc-sniffer-queries')); + $(iframeDocument.getElementById('jdbcsniffer-iframe-close')).on('click', toggle); + + incrementQueryCounter = function(numQueries) { + // increment global counter + window.jdbcSniffer.numberOfSqlQueries += numQueries; + $('.jdbc-sniffer-query-count').fill(window.jdbcSniffer.numberOfSqlQueries); + }; + + incrementQueryCounter(parseInt(sqlQueries)); + + // request data + loadQueries(location.pathname, baseUrl + 'request/' + requestId); + + loadQueries = function(url, requestDetailsUrl) { + $.request('get', requestDetailsUrl) + .then(function (data, xhr) { + + try { + statementsTableBody.add(EE('tr',[ + EE('td', {'className' : 'col-md-12 success', '@colspan' : '2'}, url) + ])); + } catch (e) { + console.log(e); + } + var noQueriesRow = EE('tr',[ + EE('td','No queries'), + EE('td','') + ]); + if (xhr.status === 200) { + var statements = $.parseJSON(data); + if (statements.length === 0) { + statementsTableBody.add(noQueriesRow); + } else { + for (var i = 0; i < statements.length; i++) { + var statement = statements[i]; + var codeEl; + statementsTableBody.add(EE('tr',[ + EE('td',[EE('div',[codeEl = EE('code',{'@class':'language-sql'},statement.query)])]), + EE('td',statement.time) + ])); + iframe.get('contentWindow').hljs.highlightBlock(codeEl[0]); + } + } + } else if (xhr.status === 204) { + statementsTableBody.add(noQueriesRow); + } + }) + .error(function (status, statusText, responseText) { + console.log(status + ' ' + statusText + ' ' + responseText); + }); + }; + + for (var i = 0; i < ajaxRequests.length; i++) { + var ajaxRequest = ajaxRequests[i]; + loadQueries(ajaxRequest.url, ajaxRequest.requestId); + } + + }); + + // Intercept ajax queries + (function(XHR) { + + var open = XHR.prototype.open; + var send = XHR.prototype.send; + + XHR.prototype.open = function(method, url, async, user, pass) { + this._url = url; + this._method = method; + open.call(this, method, url, async, user, pass); + }; + + XHR.prototype.send = function(data) { + var self = this; + var start; + var oldOnReadyStateChange; + var url = this._url; + var method = this._method; + + function onReadyStateChange() { + if(self.readyState === 4 /* complete */) { + var sqlQueries = self.getResponseHeader("X-Sql-Queries"); + if (sqlQueries && parseInt(sqlQueries) > 0) { + incrementQueryCounter(parseInt(sqlQueries)); + + var xRequestDetailsHeader = self.getResponseHeader("X-Request-Details"); // details url relative to ajax original request + + var ajaxUrl = document.createElement('a'); + ajaxUrl.href = url; + if ('' === ajaxUrl.protocol && '' === ajaxUrl.host) { + ajaxUrl.protocol = location.protocol; + ajaxUrl.host = location.host; + } + + var requestDetailsUrl = ajaxUrl.protocol + '//' + ajaxUrl.host + xRequestDetailsHeader; + var ajaxUrlLabel = + (location.protocol === ajaxUrl.protocol && location.host === ajaxUrl.host) ? + (ajaxUrl.pathname.slice(0,1) === '/' ? ajaxUrl.pathname : '/' + ajaxUrl.pathname) + + ajaxUrl.search + ajaxUrl.hash : ajaxUrl.href; + + loadQueries(method + ' ' + ajaxUrlLabel, requestDetailsUrl); + } + } + + if(oldOnReadyStateChange) { + oldOnReadyStateChange(); + } + } + + if(!this.noIntercept) { + start = new Date(); + + if(this.addEventListener) { + this.addEventListener("readystatechange", onReadyStateChange, false); + } else { + oldOnReadyStateChange = this.onreadystatechange; + this.onreadystatechange = onReadyStateChange; + } + } + + send.call(this, data); + }; + })(XMLHttpRequest); + +}.apply({})); \ No newline at end of file diff --git a/dist/jdbcsniffer.min.js b/dist/jdbcsniffer.min.js new file mode 100644 index 0000000..43e37c3 --- /dev/null +++ b/dist/jdbcsniffer.min.js @@ -0,0 +1,4 @@ +/*! jdbc-sniffer-ui - v1.2.0 - 2015-11-15 +* Copyright (c) 2015 ; Licensed BSD-3-Clause */ +(function(){function a(a){return c[a]}function b(b,d){c[b]=c[b]||d(a)}var c={};/^u/.test(typeof b)&&function(a){var b=this.require=function(b){return a[b]};this.define=function(c,d){a[c]=a[c]||d(b)}}({}),b("minified",function(){function a(a){return a.substr(0,3)}function b(a){return a!=Fa?""+a:""}function c(a){return"string"==typeof a}function d(a){return!!a&&"object"==typeof a}function e(a){return a&&a.nodeType}function f(a){return"number"==typeof a}function g(a){return d(a)&&!!a.getDay}function h(a){return!0===a||!1===a}function i(a){var b=typeof a;return"object"==b?!(!a||!a.getDay):"string"==b||"number"==b||h(a)}function j(a){return a}function k(a){return a+1}function l(a,c,d){return b(a).replace(c,d!=Fa?d:"")}function m(a){return l(a,/[\\\[\]\/{}()*+?.$|^-]/g,"\\$&")}function n(a){return l(a,/^\s+|\s+$/g)}function o(a,b,c){for(var d in a)a.hasOwnProperty(d)&&b.call(c||a,d,a[d]);return a}function p(a,b,c){if(a)for(var d=0;db?Math.max(a.length+b,0):Math.min(a.length,b)}function E(a,b,c,d){b=C(b),d=D(a,d,a.length);for(var e=D(a,c,0);d>e;e++)if((c=b.call(a,a[e],e))!=Fa)return c}function F(a,b,c,d){b=C(b),d=D(a,d,-1);for(var e=D(a,c,a.length-1);e>d;e--)if((c=b.call(a,a[e],e))!=Fa)return c}function G(a,b,c){var d=[];if(a)for(c=D(a,c,a.length),b=D(a,b,0);c>b;b++)d.push(a[b]);return d}function H(a){return v(a,j)}function I(a){return function(){return new va(O(a,arguments))}}function J(a){var b={};return q(a,function(a){return b[a]?!1:b[a]=1})}function K(a,b){var c=z(b,1);return q(a,function(a){var b=c[a];return c[a]=0,b})}function L(a,b){for(var c=0;cb?"-":"",d=(c?-b:b).toFixed(0);d.lengthf)return-W(a,c,b);if(b={milliseconds:1,seconds:1e3,minutes:6e4,hours:36e5}[a])return f/b;for(b=a.charAt(0).toUpperCase()+a.substr(1),a=Math.floor(f/{fullYear:31536e6,month:2628e6,date:864e5}[a]-2),d=U(new Date(d),b,a),f=a;1.2*a+4>f;f++)if(+U(d,b,1)>e)return f}function X(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}function Y(a){return l(a,/[\x00-\x1f'"\u2028\u2029]/g,X)}function Z(a,b){return a.split(b)}function $(a,b){function c(a,c){var d=[];return e.call(c||a,a,function(a,b){fa(a)?p(a,function(a,c){b.call(a,a,c)}):o(a,function(a,c){b.call(c,a,c)})},b||j,function(){N(d.push,d,arguments)},wa),d.join("")}if(Ma[a])return Ma[a];var d="with(_.isObject(obj)?obj:{}){"+v(Z(a,/{{|}}}?/g),function(a,b){var c,d=n(a),e=l(d,/^{/),d=d==e?"esc(":"";return b%2?(c=/^each\b(\s+([\w_]+(\s*,\s*[\w_]+)?)\s*:)?(.*)/.exec(e))?"each("+(n(c[4])?c[4]:"this")+", function("+c[2]+"){":(c=/^if\b(.*)/.exec(e))?"if("+c[1]+"){":(c=/^else\b\s*(if\b(.*))?/.exec(e))?"}else "+(c[1]?"if("+c[2]+")":"")+"{":(c=/^\/(if)?/.exec(e))?c[1]?"}\n":"});\n":(c=/^(var\s.*)/.exec(e))?c[1]+";":(c=/^#(.*)/.exec(e))?c[1]:(c=/(.*)::\s*(.*)/.exec(e))?"print("+d+'_.formatValue("'+Y(c[2])+'",'+(n(c[1])?c[1]:"this")+(d&&")")+"));\n":"print("+d+(n(e)?e:"this")+(d&&")")+");\n":a?'print("'+Y(a)+'");\n':void 0}).join("")+"}",e=Function("obj","each","esc","print","_",d);return 99'"&]/g,function(a){return"&#"+a.charCodeAt(0)+";"})}function aa(a,b){return $(a,_)(b)}function ba(a){return function(b,c){return new va(a(this,b,c))}}function ca(a){return function(b,c,d){return a(this,b,c,d)}}function da(a){return function(b,c,d){return new va(a(b,c,d))}}function ea(a){return"function"==typeof a&&!a.item}function fa(a){return a&&a.length!=Fa&&!c(a)&&!e(a)&&!ea(a)&&a!==ya}function ga(a){return parseFloat(l(a,/^[^\d-]+/))}function ha(a){return a.Nia=a.Nia||++Ba}function ia(a,b){var c,d=[],e={};return sa(a,function(a){sa(b(a),function(a){e[c=ha(a)]||(d.push(a),e[c]=!0)})}),d}function ja(a,b){var c={$position:"absolute",$visibility:"hidden",$display:"block",$height:Fa},d=a.get(c),c=a.set(c).get("clientHeight");return a.set(d),c*b+"px"}function ka(a){Ca?Ca.push(a):setTimeout(a,0)}function la(a,b,c){return pa(a,b,c)[0]}function ma(a,b,c){return a=oa(document.createElement(a)),fa(b)||b!=Fa&&!d(b)?a.add(b):a.set(b).add(c)}function na(a){return r(sa,a,function(a){return fa(a)?na(a):(e(a)&&(a=a.cloneNode(!0),a.removeAttribute&&a.removeAttribute("id")),a)})}function oa(a,b,c){return ea(a)?ka(a):new va(pa(a,b,c))}function pa(a,b,d){function f(a){return fa(a)?r(sa,a,f):a}function g(a){return q(r(sa,a,f),function(a){for(;a=a.parentNode;)if(a==b[0]||d)return a==b[0]})}return b?1!=(b=pa(b)).length?ia(b,function(b){return pa(a,b,d)}):c(a)?1!=e(b[0])?[]:d?g(b[0].querySelectorAll(a)):b[0].querySelectorAll(a):g(a):c(a)?document.querySelectorAll(a):r(sa,a,f)}function qa(a,b){function d(a,b){var c=RegExp("(^|\\s+)"+a+"(?=$|\\s)","i");return function(d){return a?c.test(d[b]):!0}}var g,h,i={},j=i;return ea(a)?a:f(a)?function(b,c){return c==a}:!a||"*"==a||c(a)&&(j=/^([\w-]*)\.?([\w-]*)$/.exec(a))?(g=d(j[1],"tagName"),h=d(j[2],"className"),function(a){return 1==e(a)&&g(a)&&h(a)}):b?function(c){return oa(a,b).find(c)!=Fa}:(oa(a).each(function(a){i[ha(a)]=!0}),function(a){return i[ha(a)]})}function ra(a){var b=qa(a);return function(a){return b(a)?Fa:!0}}function sa(a,b){return fa(a)?p(a,b):a!=Fa&&b(a,0),a}function ta(){this.state=null,this.values=[],this.parent=null}function ua(){var a,b,c=[],e=arguments,f=e.length,g=0,h=0,i=new ta;return i.errHandled=function(){h++,i.parent&&i.parent.errHandled()},a=i.fire=function(a,b){return null==i.state&&null!=a&&(i.state=!!a,i.values=fa(b)?b:[b],setTimeout(function(){p(c,function(a){a()})},0)),i},p(e,function j(b,c){try{b.then?b.then(function(b){(d(b)||ea(b))&&ea(b.then)?j(b,c):(i.values[c]=H(arguments),++g==f&&a(!0,2>f?i.values[c]:i.values))},function(){i.values[c]=H(arguments),a(!1,2>f?i.values[c]:[i.values[c][0],i.values,c])}):b(function(){a(!0,H(arguments))},function(){a(!1,H(arguments))})}catch(e){a(!1,[e,i.values,c])}}),i.stop=function(){return p(e,function(a){a.stop&&a.stop()}),i.stop0&&N(i.stop0)},b=i.then=function(a,b){function e(){try{var c=i.state?a:b;ea(c)?function g(a){try{var b,c=0;if((d(a)||ea(a))&&ea(b=a.then)){if(a===f)throw new TypeError;b.call(a,function(a){c++||g(a)},function(a){c++||f.fire(!1,[a])}),f.stop0=a.stop}else f.fire(!0,[a])}catch(e){if(!c++&&(f.fire(!1,[e]),!h))throw e}}(N(c,xa,i.values)):f.fire(i.state,i.values)}catch(e){if(f.fire(!1,[e]),!h)throw e}}var f=ua();return ea(b)&&i.errHandled(),f.stop0=i.stop,f.parent=i,null!=i.state?setTimeout(e,0):c.push(e),f},i.always=function(a){return b(a,a)},i.error=function(a){return b(0,a)},i}function va(a,b){var c,d,e,f,g,h=0;if(a)for(c=0,d=a.length;d>c;c++)if(e=a[c],b&&fa(e))for(f=0,g=e.length;g>f;f++)this[h++]=e[f];else this[h++]=e;else this[h++]=b;this.length=h,this._=!0}function wa(){return new va(arguments,!0)}var xa,ya=window,za={},Aa={},Ba=1,Ca=/^[ic]/.test(document.readyState)?Fa:[],Da={},Ea=0,Fa=null,Ga=Z("January,February,March,April,May,June,July,August,September,October,November,December",/,/g),Ha=v(Ga,a),Ia=Z("Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday",/,/g),Ja=v(Ia,a),Ka={y:["FullYear",j],Y:["FullYear",function(a){return a%100}],M:["Month",k],n:["Month",Ha],N:["Month",Ga],d:["Date",j],m:["Minutes",j],H:["Hours",j],h:["Hours",function(a){return a%12||12}],k:["Hours",k],K:["Hours",function(a){return a%12}],s:["Seconds",j],S:["Milliseconds",j],a:["Hours",Z("am,am,am,am,am,am,am,am,am,am,am,am,pm,pm,pm,pm,pm,pm,pm,pm,pm,pm,pm,pm",/,/g)],w:["Day",Ja],W:["Day",Ia],z:["TimezoneOffset",function(a,b,c){return c?c:(b=0>a?-a:a,(a>0?"-":"+")+Q(2,Math.floor(b/60))+Q(2,b%60))}]},La={y:0,Y:[0,-2e3],M:[1,1],n:[1,Ha],N:[1,Ga],d:2,m:4,H:3,h:3,K:[3,1],k:[3,1],s:5,S:6,a:[3,Z("am,pm",/,/g)]},Ma={},Na=[];return A({each:ca(p),filter:ba(q),collect:ba(s),map:ba(v),toObject:ca(z),equals:ca(M),sub:ba(G),reverse:ca(y),find:ca(E),findLast:ca(F),startsWith:ca(w),endsWith:ca(x),contains:ca(L),call:ba(O),array:ca(H),unite:ca(I),merge:ca(B),uniq:ba(J),intersection:ba(K),join:function(a){return v(this,j).join(a)},reduce:function(a,b){return p(this,function(c,d){b=a.call(this,b,c,d)}),b},sort:function(a){return new va(v(this,j).sort(a))},remove:function(){sa(this,function(a){a.parentNode.removeChild(a)})},text:function(){return r(sa,this,function(a){return a.textContent}).join("")},trav:function(a,b,c){var d=f(b),e=qa(d?Fa:b),g=d?b:c;return new va(ia(this,function(b){for(var c=[];(b=b[a])&&c.length!=g;)e(b)&&c.push(b);return c}))},next:function(a,b){return this.trav("nextSibling",a,b||1)},up:function(a,b){return this.trav("parentNode",a,b||1)},select:function(a,b){return oa(a,this,b)},is:function(a){return!this.find(ra(a))},only:function(a){return new va(q(this,qa(a)))},not:function(a){return new va(q(this,ra(a)))},get:function(a,b){var d,e,f,g,h=this,i=h[0];return i?c(a)?(d=/^(\W*)(.*)/.exec(l(a,/^%/,"@data-")),e=d[1],f=Aa[e]?Aa[e](this,d[2]):"$"==a?h.get("className"):"$$"==a?h.get("@style"):"$$slide"==a?h.get("$height"):"$$fade"==a||"$$show"==a?"hidden"==h.get("$visibility")||"none"==h.get("$display")?0:"$$fade"==a?isNaN(h.get("$opacity",!0))?1:h.get("$opacity",!0):1:"$"==e?ya.getComputedStyle(i,Fa).getPropertyValue(l(d[2],/[A-Z]/g,function(a){return"-"+a.toLowerCase()})):"@"==e?i.getAttribute(d[2]):i[d[2]],b?ga(f):f):(g={},(fa(a)?sa:o)(a,function(a){g[a]=h.get(a,b)}),g):void 0},set:function(a,b){var d,e,f=this;return b!==xa?(d=/^(\W*)(.*)/.exec(l(l(a,/^\$float$/,"cssFloat"),/^%/,"@data-")),e=d[1],za[e]?za[e](this,d[2],b):"$$fade"==a?this.set({$visibility:b?"visible":"hidden",$opacity:b}):"$$slide"==a?f.set({$visibility:b?"visible":"hidden",$overflow:"hidden",$height:/px/.test(b)?b:function(a,c,d){return ja(oa(d),b)}}):"$$show"==a?b?f.set({$visibility:b?"visible":"hidden",$display:""}).set({$display:function(a){return"none"==a?"block":a}}):f.set({$display:"none"}):"$$"==a?f.set("@style",b):sa(this,function(c,f){var g=ea(b)?b(oa(c).get(a),f,c):b;"$"==e?d[2]?c.style[d[2]]=g:sa(g&&g.split(/\s+/),function(a){var b=l(a,/^[+-]/),d=c.className||"",e=l(d,RegExp("(^|\\s+)"+b+"(?=$|\\s)"));(/^\+/.test(a)||b==a&&d==e)&&(e+=" "+b),c.className=n(e)}):"$$scrollX"==a?c.scroll(g,oa(c).get("$$scrollY")):"$$scrollY"==a?c.scroll(oa(c).get("$$scrollX"),g):"@"==e?g==Fa?c.removeAttribute(d[2]):c.setAttribute(d[2],g):c[d[2]]=g})):c(a)||ea(a)?f.set("$",a):o(a,function(a,b){f.set(a,b)}),f},show:function(){return this.set("$$show",1)},hide:function(){return this.set("$$show",0)},add:function(a,b){return this.each(function(c,d){function f(a){fa(a)?sa(a,f):ea(a)?f(a(c,d)):a!=Fa&&(a=e(a)?a:document.createTextNode(a),g?g.parentNode.insertBefore(a,g.nextSibling):b?b(a,c,c.parentNode):c.appendChild(a),g=a)}var g;f(d&&!ea(a)?na(a):a)})},fill:function(a){return this.each(function(a){oa(a.childNodes).remove()}).add(a)},addAfter:function(a){return this.add(a,function(a,b,c){c.insertBefore(a,b.nextSibling)})},addBefore:function(a){return this.add(a,function(a,b,c){c.insertBefore(a,b)})},addFront:function(a){return this.add(a,function(a,b){b.insertBefore(a,b.firstChild)})},replace:function(a){return this.add(a,function(a,b,c){c.replaceChild(a,b)})},clone:ba(na),animate:function(a,b,c){var d,e=ua(),f=this,g=r(sa,this,function(b,d){var e,f=oa(b),g={};return o(e=f.get(a),function(c,e){var h=a[c];g[c]=ea(h)?h(e,d,b):"$$slide"==c?ja(f,h):h}),f.dial(e,g,c)}),h=b||500;return e.stop0=function(){return e.fire(!1),d()},d=oa.loop(function(a){O(g,[a/h]),a>=h&&(d(),e.fire(!0,[f]))}),e},dial:function(a,c,d){function e(a,b){return/^#/.test(a)?parseInt(6=d?g:d>=1?i:/^#|rgb\(/.test(i)?"rgb("+Math.round(h(e(g,j),e(i,j++),d))+","+Math.round(h(e(g,j),e(i,j++),d))+","+Math.round(h(e(g,j),e(i,j++),d))+")":l(i,/-?[\d.]+/,b(h(ga(g),ga(i),d))))})}},toggle:function(a,b,c,d){var e,f,g=this,h=!1;return b?(g.set(a),function(i){i!==h&&(f=(h=!0===i||!1===i?i:!h)?b:a,c?(e=g.animate(f,e?e.stop():c,d)).then(function(){e=Fa}):g.set(f))}):g.toggle(l(a,/\b(?=\w)/g,"-"),l(a,/\b(?=\w)/g,"+"))},values:function(a){var c=a||{};return this.each(function(a){var d=a.name||a.id,e=b(a.value);if(/form/i.test(a.tagName))for(d=0;dd;d++)a.call(this,new va(Fa,this[d]),d);else oa(a,this).per(b);return this},ht:function(a,b){var c=2f.status?h.fire(!0,[f.responseText,f]):h.fire(!1,[f.status,f.responseText,f]))},f.send(d)}catch(j){g||h.fire(!1,[0,Fa,b(j)])}return h},toJSON:JSON.stringify,parseJSON:JSON.parse,ready:ka,loop:function(a){function b(a){o(Da,function(b,c){c(a)}),Ea&&g(b)}function c(){return Da[f]&&(delete Da[f],Ea--),e}var d,e=0,f=Ba++,g=ya.requestAnimationFrame||function(a){setTimeout(function(){a(+new Date)},33)};return Da[f]=function(b){d=d||b,a(e=b-d,c)},Ea++||g(b),c},off:function(a){O(a.M),a.M=Fa},setCookie:function(a,b,c,e){document.cookie=a+"="+(e?b:escape(b))+(c?"; expires="+(d(c)?c:new Date(+new Date+864e5*c)).toUTCString():"")},getCookie:function(a,b){var c,d=(c=RegExp("(^|;)\\s*"+a+"=([^;]*)").exec(document.cookie))&&c[2];return b?d:d&&unescape(d)},wait:function(a,b){var c=ua(),d=setTimeout(function(){c.fire(!0,b)},a);return c.stop0=function(){c.fire(!1),clearTimeout(d)},c}},oa),A({filter:da(q),collect:da(s),map:da(v),sub:da(G),reverse:y,each:p,toObject:z,find:E,findLast:F,contains:L,startsWith:w,endsWith:x,equals:M,call:da(O),array:H,unite:I,merge:B,uniq:da(J),intersection:da(K),keys:da(u),values:da(function(a,b){var c=[];return b?p(b,function(b){c.push(a[b])}):o(a,function(a,b){c.push(b)}),c}),copyObj:A,extend:function(a){return B(G(arguments,1),a)},range:function(a,b){for(var c=[],d=b==Fa?a:b,e=b!=Fa?a:0;d>e;e++)c.push(e);return new va(c)},bind:P,partial:function(a,b,c){return P(a,this,b,c)},eachObj:o,mapObj:function(a,b,c){var d={};return o(a,function(e,f){d[e]=b.call(c||a,e,f)}),d},filterObj:function(a,b,c){var d={};return o(a,function(e,f){b.call(c||a,e,f)&&(d[e]=f)}),d},isList:fa,isFunction:ea,isObject:d,isNumber:f,isBool:h,isDate:g,isValue:i,isString:c,toString:b,dateClone:T,dateAdd:V,dateDiff:W,dateMidnight:function(a){return a=a||new Date,new Date(a.getFullYear(),a.getMonth(),a.getDate())},pad:Q,formatValue:function(a,d){var e,h,i=l(a,/^\?/);return g(d)?((h=/^\[(([+-])(\d\d)(\d\d))\]\s*(.*)/.exec(i))&&(e=h[1],d=V(d,"minutes",S(h,2,d)),i=h[5]),l(i,/(\w)(\1*)(?:\[([^\]]+)\])?/g,function(a,b,f,g){return(b=Ka[b])&&(a=d["get"+b[0]](),g=g&&g.split(","),a=fa(b[1])?(g||b[1])[a]:b[1](a,g,e),a==Fa||c(a)||(a=Q(f.length+1,a))),a})):E(i.split(/\s*\|\s*/),function(a){var c,e;if(c=/^([<>]?)(=?)([^:]*?)\s*:\s*(.*)$/.exec(a)){if(a=d,e=+c[3],(isNaN(e)||!f(a))&&(a=a==Fa?"null":b(a),e=c[3]),c[1]){if(!c[2]&&a==e||"<"==c[1]&&a>e||">"==c[1]&&e>a)return Fa}else if(a!=e)return Fa;c=c[4]}else c=a;return f(d)?c.replace(/[0#](.*[0#])?/,function(a){var b,c=/^([^.]+)(\.)([^.]+)$/.exec(a)||/^([^,]+)(,)([^,]+)$/.exec(a),e=0>d?"-":"",f=/(\d+)(\.(\d+))?/.exec((e?-d:d).toFixed(c?c[3].length:0));return a=c?c[1]:a,b=c?R(c[3],l(f[3],/0+$/),!0):"",(e?"-":"")+("#"==a?f[1]:R(a,f[1]))+(b.length?c[2]:"")+b}):c})},parseDate:function(a,b){var c,d,e,f,g,h,i,j,k,o={},p=1,q=l(a,/^\?/);if(q!=a&&!n(b))return Fa;if((e=/^\[([+-])(\d\d)(\d\d)\]\s*(.*)/.exec(q))&&(c=e,q=e[4]),!(e=RegExp(q.replace(/(.)(\1*)(?:\[([^\]]*)\])?/g,function(a,b,c,e){return/[dmhkyhs]/i.test(b)?(o[p++]=b,a=c.length+1,"(\\d"+(2>a?"+":"{1,"+a+"}")+")"):"z"==b?(d=p,p+=3,"([+-])(\\d\\d)(\\d\\d)"):/[Nna]/.test(b)?(o[p++]=[b,e&&e.split(",")],"([a-zA-Z\\u0080-\\u1fff]+)"):/w/i.test(b)?"[a-zA-Z\\u0080-\\u1fff]+":/\s/.test(b)?"\\s+":m(a)})).exec(b)))return xa;for(q=[0,0,0,0,0,0,0],f=1;p>f;f++)if(g=e[f],h=o[f],fa(h)){if(i=h[0],j=La[i],k=j[0],h=E(h[1]||j[1],function(a,b){return w(g.toLowerCase(),a.toLowerCase())?b:void 0}),h==Fa)return xa;q[k]="a"==i?q[k]+12*h:h}else h&&(i=parseFloat(g),j=La[h],fa(j)?q[j[0]]+=i-j[1]:q[j]+=i);return q=new Date(q[0],q[1],q[2],q[3],q[4],q[5],q[6]),V(q,"minutes",-S(c,1,q)-S(e,d,q))},parseNumber:function(a,b){var c=l(a,/^\?/);return c==a||n(b)?(c=/(^|[^0#.,])(,|[0#.]*,[0#]+|[0#]+\.[0#]+\.[0#.,]*)($|[^0#.,])/.test(c)?",":".",c=parseFloat(l(l(l(b,","==c?/\./g:/,/g),c,"."),/^[^\d-]*(-?\d)/,"$1")),isNaN(c)?xa:c):Fa},trim:n,isEmpty:function(a,b){return a==Fa||!a.length||b&&/^\s*$/.test(a)},escapeRegExp:m,escapeHtml:_,format:function(a,b,c){return $(a,c)(b)},template:$,formatHtml:aa,promise:ua},wa),document.addEventListener("DOMContentLoaded",function(){O(Ca),Ca=Fa},!1),{HTML:function(){var a=ma("div");return wa(N(a.ht,a,arguments)[0].childNodes)},_:wa,$:oa,$$:la,EE:ma,M:va,getter:Aa,setter:za}});var d=a("minified"),e=d.$,f=d.EE;d.HTML;window.jdbcSniffer={numberOfSqlQueries:0};var g=[],h=function(a,b){g.push({url:a,requestId:b})},i=function(a){window.jdbcSniffer.numberOfSqlQueries+=a};e(function(){var a=function(){e("body *").filter(function(a,b){return"2147483647"===e(a).get("$zIndex")&&"jdbc-sniffer-query-count"!==e(a).get("$")}).set("$zIndex","2147483646")};a(),window.setTimeout(a,10),window.setTimeout(a,100),window.setTimeout(a,1e3),window.setTimeout(a,2e3);var b=e("#jdbc-sniffer-header"),c=b.get("%request-id"),d=b.get("@src"),j=d.substring(0,d.lastIndexOf("/")+1),k=e("#jdbc-sniffer"),l=k.get("%sql-queries");e("head").add(f("style",".jdbc-sniffer-iframe{border:0;margin:auto;width:100%;height:95%;left:0;right:0;top:0;bottom:0;position:fixed;z-index:2147483647}@media (min-width:768px){.jdbc-sniffer-iframe{width:750px}}@media (min-width:992px){.jdbc-sniffer-iframe{width:970px}}@media (min-width:1200px){.jdbc-sniffer-iframe{width:1170px}}.jdbc-sniffer-query-count{color:red;text-align:center;font-weight:bold;position:fixed;right:20px;bottom:20px;width:24px;height:24px;background-size:100%;z-index:9999999990;opacity:1;font-size:16px !important;line-height:normal !important;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADAklEQVRIibWWzWscdRzGP59hCEGWEEIstZYQQntICbnqxYuI4E0EPcQ/QQ9eJd7s4lEEUfCil+5JL8WLJ98u6qmEkMUXqgQsNYRYllJKCPN4mNmd2aTZouBv2d1nZn6/5/v6fHcFGOxdB10GNoCNwFXCKuSiupRkAZxTCpICrCLHkJFwGDgQ94FfgT1gl3Bn69o2Dvb6a8i7wAvAcqCQdgXw3+FKOAK+S/J2ibwBbI0JTx/yFB5fzMAFYRl5Rb1dAkXX3RBE7IQxHVFqsm6I52BhvpyKT3CK7uxy4vLZ3DwKFy3fKc/OWWk2pXnNxAkFUJFuMrvRnv1sTraXM7BIAXyPHpzNXxvnNBYUdTbGO8DXAtwYXr8sPg88B2wCVwJLj0rvjHUI/ELYQb4Fvtla377rYNhfS3L4+rV3Rt3dg2G/l3DRWhs9pSR1zRIq5RgYEY6Qg6317fvd8zeG/UVh2cGw/wHwMuGHmB/F3YQ/lFGSh8ix8QSppitkAZTAXMK8spiwhmwIz0CeBT8vSUBXkBXxNQBrspFwL/AAeUA4QaqQohZfSuITSk+zkLCgtppCEooSrcZOpS1oEVgUF22aoyOVutQJ2FQntMKcbK7FWkITuh3LnVym86yma1xoGGdi6jExKU7bKZnyeMr7tN+PxTAqgfeAv0heRTeSLE+8bFg7UbdpoXtzgquQA3UX+CLJZyVwAnwEfpKwhF4CrggrwFPAEtID5gllasGfBB4KI+Ao+CdhX/lNvdu0bqWWJeRN8GnkK+En4NbW+vYt/sMa7PVBFjEvgi8BvzsY9t8H3mpGdYXuQ24b9pFDwt/gCDkmnDRcZcic2kvyJHihbvOsES7VI0iAD8uJ+TqHhbAaXG1SQWwfT+7RGeu2Az6d35E05eoI43/oImsDx2OTCfWYjQ1uzHVw3UVjS4/DVAXwKeRL5F7trnVamvdEaGM8FqKeg6kCRyQ3gY8FGAz7BeEysAnZRK9St+kFYAno0aSzHl0h9QC8b012AOyjPwM7wM74b8s/Owp6BPc7ajsAAAAASUVORK5CYII=)}.jdbc-sniffer-query-count:hover{cursor:pointer}"));var m=f("iframe",{$display:"none",className:"jdbc-sniffer-iframe","@scrolling":"no"});e("body").add(m);var n=m.toggle({$display:"none"},{$display:"block"}),o=f("div",{className:"jdbc-sniffer-query-count"},l);o.on("click",n),e("body").add(o);var p='JDBC Sniffer

Executed Queries

QueryTime
',q=m.get("contentWindow").document; +q.open(),q.write(p),q.close();var r=e(q.getElementById("jdbc-sniffer-queries"));e(q.getElementById("jdbcsniffer-iframe-close")).on("click",n),i=function(a){window.jdbcSniffer.numberOfSqlQueries+=a,e(".jdbc-sniffer-query-count").fill(window.jdbcSniffer.numberOfSqlQueries)},i(parseInt(l)),h(location.pathname,j+"request/"+c),h=function(a,b){e.request("get",b).then(function(b,c){try{r.add(f("tr",[f("td",{className:"col-md-12 success","@colspan":"2"},a)]))}catch(d){console.log(d)}var g=f("tr",[f("td","No queries"),f("td","")]);if(200===c.status){var h=e.parseJSON(b);if(0===h.length)r.add(g);else for(var i=0;i0){i(parseInt(a));var b=f.getResponseHeader("X-Request-Details"),c=document.createElement("a");c.href=g,""===c.protocol&&""===c.host&&(c.protocol=location.protocol,c.host=location.host);var d=c.protocol+"//"+c.host+b,k=location.protocol===c.protocol&&location.host===c.host?("/"===c.pathname.slice(0,1)?c.pathname:"/"+c.pathname)+c.search+c.hash:c.href;h(j+" "+k,d)}}e&&e()}var d,e,f=this,g=this._url,j=this._method;this.noIntercept||(d=new Date,this.addEventListener?this.addEventListener("readystatechange",b,!1):(e=this.onreadystatechange,this.onreadystatechange=b)),c.call(this,a)}}(XMLHttpRequest)}).apply({}); \ No newline at end of file diff --git a/index.js b/index.js index 23f5e6e..4c54959 100755 --- a/index.js +++ b/index.js @@ -5,7 +5,9 @@ var counter = 1000; app.get('/mock/ajax.json', function (req, res) { res.header('X-Sql-Queries' , 2 ); - res.header('X-Request-Id' , 'a54b32e7-b94b-450b-b145-0cf62270d32a' ); + //res.header('X-Request-Id' , 'a54b32e7-b94b-450b-b145-0cf62270d32a' ); + res.header('X-Request-Details' , '/mock/request/a54b32e7-b94b-450b-b145-0cf62270d32a' ); + res.send('{"foo":"bar","baz":42}'); }); diff --git a/mock/.gitignore b/mock/.gitignore new file mode 100644 index 0000000..dd4ab8b --- /dev/null +++ b/mock/.gitignore @@ -0,0 +1,3 @@ +jdbcsniffer.js + +jdbcsniffer.min.js \ No newline at end of file diff --git a/mock/frame.html b/mock/frame.html index 3c6e6d7..a6a6a40 100755 --- a/mock/frame.html +++ b/mock/frame.html @@ -1,10 +1,11 @@ + JDBC Sniffer Integration

Invisible IFrame

+ - \ No newline at end of file diff --git a/mock/mock.html b/mock/mock.html index 9dc26c7..b596dfa 100755 --- a/mock/mock.html +++ b/mock/mock.html @@ -1,6 +1,7 @@ + JDBC Sniffer Integration

JDBC Sniffer Integration

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+

"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."

+ - \ No newline at end of file diff --git a/mock/request/a54b32e7-b94b-450b-b145-0cf62270d32a b/mock/request/a54b32e7-b94b-450b-b145-0cf62270d32a index e79a02f..b240619 100755 --- a/mock/request/a54b32e7-b94b-450b-b145-0cf62270d32a +++ b/mock/request/a54b32e7-b94b-450b-b145-0cf62270d32a @@ -1,4 +1,4 @@ [ -{"query":"SELECT 1 FROM DUAL","time":300}, +{"query":"select distinct owner0_.id as id1_0_0_, pets1_.id as id1_1_1_, owner0_.first_name as first_na2_0_0_, owner0_.last_name as last_nam3_0_0_, owner0_.address as address4_0_0_, owner0_.city as city5_0_0_, owner0_.telephone as telephon6_0_0_, pets1_.name as name2_1_1_, pets1_.birth_date as birth_da3_1_1_, pets1_.owner_id as owner_id4_1_1_, pets1_.type_id as type_id5_1_1_, pets1_.owner_id as owner_id4_0_0__, pets1_.id as id1_1_0__ from owners owner0_ left outer join pets pets1_ on owner0_.id=pets1_.owner_id where owner0_.last_name like ?","time":300}, {"query":"SELECT 1 FROM DUAL","time":300} ] \ No newline at end of file diff --git a/package.json b/package.json index 7ecd68c..b35805b 100755 --- a/package.json +++ b/package.json @@ -3,24 +3,28 @@ "title": "UI for JDBC Sniffer", "author": "bedrin ", "license": "BSD-3-Clause", - "version": "1.1.0", + "version": "1.2.0", "repository": { "type": "git", "url": "https://github.com/bedrin/jdbc-sniffer-ui.git" }, + "scripts": { + "test": "grunt travis" + }, "dependencies": { "express": "^4.13.3" }, "devDependencies": { - "grunt": "~0.4.2", - "grunt-contrib-concat": "~0.3.0", + "bower": "^1.5.3", + "grunt": "^0.4.5", "grunt-contrib-copy": "^0.8.0", "grunt-contrib-htmlmin": "^0.4.0", "grunt-contrib-jshint": "~0.7.2", "grunt-contrib-less": "^1.0.1", - "grunt-contrib-qunit": "*", "grunt-contrib-uglify": "~0.9.1", "grunt-contrib-watch": "~0.5.3", - "grunt-include-replace": "^3.0.0" + "grunt-include-replace": "^3.0.0", + "grunt-notify": "^0.4.1", + "grunt-image-embed": "^0.3.3" } } diff --git a/src/jdbcsniffer.html b/src/jdbcsniffer.html deleted file mode 100755 index 3c95014..0000000 --- a/src/jdbcsniffer.html +++ /dev/null @@ -1,47 +0,0 @@ - \ No newline at end of file diff --git a/src/jdbcsniffer.iframe.html b/src/jdbcsniffer.iframe.html new file mode 100644 index 0000000..c882809 --- /dev/null +++ b/src/jdbcsniffer.iframe.html @@ -0,0 +1,44 @@ + + + + JDBC Sniffer + + + +
+
+
+ + +
+

Executed Queries

+
+
+ + + + + + + + + +
QueryTime
+
+ +
+ + + \ No newline at end of file diff --git a/src/jdbcsniffer.js b/src/jdbcsniffer.js index 36f08cd..90226f4 100755 --- a/src/jdbcsniffer.js +++ b/src/jdbcsniffer.js @@ -1,10 +1,31 @@ ;(function(){ + /*jshint unused:false*/ + + // require/define basic support + + var defs = {}; + + function require(name) { + return defs[name]; + } + + function define(name, f) { + defs[name] = defs[name] || f(require); + } + + // include libraries: minified.js + //@@include('../bower_components/minified/dist/minified.js') + var MINI = require('minified'); var $ = MINI.$, EE = MINI.EE, HTML = MINI.HTML; - window.jdbcSniffer = {numberOfSqlQueries : 0}; + // register jdbcSniffer in global scope + + window.jdbcSniffer = { + numberOfSqlQueries : 0 + }; var ajaxRequests = []; var loadQueries = function(url, requestId) { @@ -12,41 +33,58 @@ }; var incrementQueryCounter = function(numQueries) { + // increment global counter window.jdbcSniffer.numberOfSqlQueries += numQueries; }; + // setup sniffer UI on dom ready + $(function(){ + var fixZIndex = function() { + $('body *').filter(function(el, index){ + return $(el).get('$zIndex') === '2147483647' && $(el).get('$') !== 'jdbc-sniffer-query-count'; + }).set('$zIndex','2147483646'); + }; + fixZIndex(); + window.setTimeout(fixZIndex, 10); + window.setTimeout(fixZIndex, 100); + window.setTimeout(fixZIndex, 1000); + window.setTimeout(fixZIndex, 2000); + + var snifferHeaderElement = $('#jdbc-sniffer-header'); + var requestId = snifferHeaderElement.get('%request-id'); + var snifferScriptSrc = snifferHeaderElement.get('@src'); + var baseUrl = snifferScriptSrc.substring(0, snifferScriptSrc.lastIndexOf('/') + 1); + var snifferElement = $('#jdbc-sniffer'); var sqlQueries = snifferElement.get('%sql-queries'); - var requestId = snifferElement.get('%request-id'); - var snifferScriptSrc = snifferElement.get('@src'); - - var baseUrl = snifferScriptSrc.substring(0, snifferScriptSrc.lastIndexOf('/') + 1); // inject stylesheet - var snifferStyleHref = baseUrl + 'jdbcsniffer.css'; - $('head').add(EE('link', { - '@rel' : 'stylesheet', - '@type' : 'text.css', - '@href' : snifferStyleHref, - '@media' : 'all' - })); + $('head').add(EE('style', '//@@include("../build/jdbcsniffer.css")')); // create main GUI - var queryList = HTML( - '//@@include("../dist/jdbcsniffer.html")' - ); - - $('body').add(queryList); - var toggle = queryList.toggle({'$display': 'none'}, {'$display': 'block'}); - $('button.close', queryList).on('click', toggle); + var iframe = EE('iframe', {'$display' : 'none', 'className' : 'jdbc-sniffer-iframe', '@scrolling' : 'no'}); + $('body').add(iframe); + var toggle = iframe.toggle({'$display': 'none'}, {'$display': 'block'}); + // append toolbar var queryCounterDiv = EE('div', { 'className' : 'jdbc-sniffer-query-count' }, sqlQueries); queryCounterDiv.on('click', toggle); $('body').add(queryCounterDiv); + // create iframe GUI + + var iframeHtml = '//@@include("../build/jdbcsniffer.iframe.html")'; + var iframeDocument = iframe.get('contentWindow').document; + iframeDocument.open(); + iframeDocument.write(iframeHtml); + iframeDocument.close(); + + var statementsTableBody = $(iframeDocument.getElementById('jdbc-sniffer-queries')); + $(iframeDocument.getElementById('jdbcsniffer-iframe-close')).on('click', toggle); + incrementQueryCounter = function(numQueries) { // increment global counter window.jdbcSniffer.numberOfSqlQueries += numQueries; @@ -56,15 +94,19 @@ incrementQueryCounter(parseInt(sqlQueries)); // request data - loadQueries(location.pathname, requestId); + loadQueries(location.pathname, baseUrl + 'request/' + requestId); - loadQueries = function(url, requestId) { - $.request('get', baseUrl + 'request/' + requestId) + loadQueries = function(url, requestDetailsUrl) { + $.request('get', requestDetailsUrl) .then(function (data, xhr) { - var statementsTableBody = $('#jdbc-sniffer-queries'); - statementsTableBody.add(EE('tr',[ - EE('td', {'className' : 'col-md-12 success', '@colspan' : '2'}, url) - ])); + + try { + statementsTableBody.add(EE('tr',[ + EE('td', {'className' : 'col-md-12 success', '@colspan' : '2'}, url) + ])); + } catch (e) { + console.log(e); + } var noQueriesRow = EE('tr',[ EE('td','No queries'), EE('td','') @@ -76,10 +118,12 @@ } else { for (var i = 0; i < statements.length; i++) { var statement = statements[i]; + var codeEl; statementsTableBody.add(EE('tr',[ - EE('td',statement.query), + EE('td',[EE('div',[codeEl = EE('code',{'@class':'language-sql'},statement.query)])]), EE('td',statement.time) ])); + iframe.get('contentWindow').hljs.highlightBlock(codeEl[0]); } } } else if (xhr.status === 204) { @@ -122,10 +166,23 @@ var sqlQueries = self.getResponseHeader("X-Sql-Queries"); if (sqlQueries && parseInt(sqlQueries) > 0) { incrementQueryCounter(parseInt(sqlQueries)); - var requestId = self.getResponseHeader("X-Request-Id"); - url = url.charAt(0) === '/' ? url : - location.pathname.substring(0, location.pathname.lastIndexOf('/') + 1) + url; - loadQueries(method + ' ' + url, requestId); + + var xRequestDetailsHeader = self.getResponseHeader("X-Request-Details"); // details url relative to ajax original request + + var ajaxUrl = document.createElement('a'); + ajaxUrl.href = url; + if ('' === ajaxUrl.protocol && '' === ajaxUrl.host) { + ajaxUrl.protocol = location.protocol; + ajaxUrl.host = location.host; + } + + var requestDetailsUrl = ajaxUrl.protocol + '//' + ajaxUrl.host + xRequestDetailsHeader; + var ajaxUrlLabel = + (location.protocol === ajaxUrl.protocol && location.host === ajaxUrl.host) ? + (ajaxUrl.pathname.slice(0,1) === '/' ? ajaxUrl.pathname : '/' + ajaxUrl.pathname) + + ajaxUrl.search + ajaxUrl.hash : ajaxUrl.href; + + loadQueries(method + ' ' + ajaxUrlLabel, requestDetailsUrl); } } @@ -149,4 +206,4 @@ }; })(XMLHttpRequest); -}()); \ No newline at end of file +}.apply({})); \ No newline at end of file diff --git a/src/jdbcsniffer.less b/src/jdbcsniffer.less index 70930e3..eb37fa3 100755 --- a/src/jdbcsniffer.less +++ b/src/jdbcsniffer.less @@ -1,16 +1,26 @@ -.jdbc-sniffer-ui { - @import (less) "../bower_components/bootstrap/dist/css/bootstrap.css"; - //@icon-font-path: ''; +.jdbc-sniffer-iframe { + border: 0; + margin: auto; width: 100%; - height: 100%; - left: 0px; - top: 0px; - position: absolute; - z-index:9999999991; -} + height: 95%; + left: 0; + right: 0; + top: 0; + bottom: 0; + position: fixed; + z-index:2147483647; + + @media (min-width: 768px) { + width: 750px; + } -.jdbc-sniffer-ui > div { - padding-top: 25px; + @media (min-width: 992px) { + width: 970px; + } + + @media (min-width: 1200px) { + width: 1170px; + } } .jdbc-sniffer-query-count { @@ -25,9 +35,11 @@ background-size:100%; z-index:9999999990; opacity:1.0; + font-size: 16px !important; + line-height: normal !important; background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAADAklEQVRIibWWzWscdRzGP59hCEGWEEIstZYQQntICbnqxYuI4E0EPcQ/QQ9eJd7s4lEEUfCil+5JL8WLJ98u6qmEkMUXqgQsNYRYllJKCPN4mNmd2aTZouBv2d1nZn6/5/v6fHcFGOxdB10GNoCNwFXCKuSiupRkAZxTCpICrCLHkJFwGDgQ94FfgT1gl3Bn69o2Dvb6a8i7wAvAcqCQdgXw3+FKOAK+S/J2ibwBbI0JTx/yFB5fzMAFYRl5Rb1dAkXX3RBE7IQxHVFqsm6I52BhvpyKT3CK7uxy4vLZ3DwKFy3fKc/OWWk2pXnNxAkFUJFuMrvRnv1sTraXM7BIAXyPHpzNXxvnNBYUdTbGO8DXAtwYXr8sPg88B2wCVwJLj0rvjHUI/ELYQb4Fvtla377rYNhfS3L4+rV3Rt3dg2G/l3DRWhs9pSR1zRIq5RgYEY6Qg6317fvd8zeG/UVh2cGw/wHwMuGHmB/F3YQ/lFGSh8ix8QSppitkAZTAXMK8spiwhmwIz0CeBT8vSUBXkBXxNQBrspFwL/AAeUA4QaqQohZfSuITSk+zkLCgtppCEooSrcZOpS1oEVgUF22aoyOVutQJ2FQntMKcbK7FWkITuh3LnVym86yma1xoGGdi6jExKU7bKZnyeMr7tN+PxTAqgfeAv0heRTeSLE+8bFg7UbdpoXtzgquQA3UX+CLJZyVwAnwEfpKwhF4CrggrwFPAEtID5gllasGfBB4KI+Ao+CdhX/lNvdu0bqWWJeRN8GnkK+En4NbW+vYt/sMa7PVBFjEvgi8BvzsY9t8H3mpGdYXuQ24b9pFDwt/gCDkmnDRcZcic2kvyJHihbvOsES7VI0iAD8uJ+TqHhbAaXG1SQWwfT+7RGeu2Az6d35E05eoI43/oImsDx2OTCfWYjQ1uzHVw3UVjS4/DVAXwKeRL5F7trnVamvdEaGM8FqKeg6kCRyQ3gY8FGAz7BeEysAnZRK9St+kFYAno0aSzHl0h9QC8b012AOyjPwM7wM74b8s/Owp6BPc7ajsAAAAASUVORK5CYII=); -} -.jdbc-sniffer-query-count:hover { - cursor: pointer; + &:hover { + cursor: pointer; + } } \ No newline at end of file diff --git a/vendor/highlight.js b/vendor/highlight.js new file mode 100644 index 0000000..b0d5b0d --- /dev/null +++ b/vendor/highlight.js @@ -0,0 +1 @@ +!function(e){"undefined"!=typeof exports?e(exports):(window.hljs=e({}),"function"==typeof define&&define.amd&&define("hljs",[],function(){return window.hljs}))}(function(e){function n(e){return e.replace(/&/gm,"&").replace(//gm,">")}function t(e){return e.nodeName.toLowerCase()}function r(e,n){var t=e&&e.exec(n);return t&&0==t.index}function a(e){return/^(no-?highlight|plain|text)$/i.test(e)}function i(e){var n,t,r,i=e.className+" ";if(i+=e.parentNode?e.parentNode.className:"",t=/\blang(?:uage)?-([\w-]+)\b/i.exec(i))return w(t[1])?t[1]:"no-highlight";for(i=i.split(/\s+/),n=0,r=i.length;r>n;n++)if(w(i[n])||a(i[n]))return i[n]}function o(e,n){var t,r={};for(t in e)r[t]=e[t];if(n)for(t in n)r[t]=n[t];return r}function u(e){var n=[];return function r(e,a){for(var i=e.firstChild;i;i=i.nextSibling)3==i.nodeType?a+=i.nodeValue.length:1==i.nodeType&&(n.push({event:"start",offset:a,node:i}),a=r(i,a),t(i).match(/br|hr|img|input/)||n.push({event:"stop",offset:a,node:i}));return a}(e,0),n}function c(e,r,a){function i(){return e.length&&r.length?e[0].offset!=r[0].offset?e[0].offset"}function u(e){l+=""}function c(e){("start"==e.event?o:u)(e.node)}for(var s=0,l="",f=[];e.length||r.length;){var g=i();if(l+=n(a.substr(s,g[0].offset-s)),s=g[0].offset,g==e){f.reverse().forEach(u);do c(g.splice(0,1)[0]),g=i();while(g==e&&g.length&&g[0].offset==s);f.reverse().forEach(o)}else"start"==g[0].event?f.push(g[0].node):f.pop(),c(g.splice(0,1)[0])}return l+n(a.substr(s))}function s(e){function n(e){return e&&e.source||e}function t(t,r){return new RegExp(n(t),"m"+(e.cI?"i":"")+(r?"g":""))}function r(a,i){if(!a.compiled){if(a.compiled=!0,a.k=a.k||a.bK,a.k){var u={},c=function(n,t){e.cI&&(t=t.toLowerCase()),t.split(" ").forEach(function(e){var t=e.split("|");u[t[0]]=[n,t[1]?Number(t[1]):1]})};"string"==typeof a.k?c("keyword",a.k):Object.keys(a.k).forEach(function(e){c(e,a.k[e])}),a.k=u}a.lR=t(a.l||/\b\w+\b/,!0),i&&(a.bK&&(a.b="\\b("+a.bK.split(" ").join("|")+")\\b"),a.b||(a.b=/\B|\b/),a.bR=t(a.b),a.e||a.eW||(a.e=/\B|\b/),a.e&&(a.eR=t(a.e)),a.tE=n(a.e)||"",a.eW&&i.tE&&(a.tE+=(a.e?"|":"")+i.tE)),a.i&&(a.iR=t(a.i)),void 0===a.r&&(a.r=1),a.c||(a.c=[]);var s=[];a.c.forEach(function(e){e.v?e.v.forEach(function(n){s.push(o(e,n))}):s.push("self"==e?a:e)}),a.c=s,a.c.forEach(function(e){r(e,a)}),a.starts&&r(a.starts,i);var l=a.c.map(function(e){return e.bK?"\\.?("+e.b+")\\.?":e.b}).concat([a.tE,a.i]).map(n).filter(Boolean);a.t=l.length?t(l.join("|"),!0):{exec:function(){return null}}}}r(e)}function l(e,t,a,i){function o(e,n){for(var t=0;t";return i+=e+'">',i+n+o}function p(){if(!L.k)return n(M);var e="",t=0;L.lR.lastIndex=0;for(var r=L.lR.exec(M);r;){e+=n(M.substr(t,r.index-t));var a=g(L,r);a?(B+=a[1],e+=h(a[0],n(r[0]))):e+=n(r[0]),t=L.lR.lastIndex,r=L.lR.exec(M)}return e+n(M.substr(t))}function d(){var e="string"==typeof L.sL;if(e&&!x[L.sL])return n(M);var t=e?l(L.sL,M,!0,y[L.sL]):f(M,L.sL.length?L.sL:void 0);return L.r>0&&(B+=t.r),e&&(y[L.sL]=t.top),h(t.language,t.value,!1,!0)}function b(){return void 0!==L.sL?d():p()}function v(e,t){var r=e.cN?h(e.cN,"",!0):"";e.rB?(k+=r,M=""):e.eB?(k+=n(t)+r,M=""):(k+=r,M=t),L=Object.create(e,{parent:{value:L}})}function m(e,t){if(M+=e,void 0===t)return k+=b(),0;var r=o(t,L);if(r)return k+=b(),v(r,t),r.rB?0:t.length;var a=u(L,t);if(a){var i=L;i.rE||i.eE||(M+=t),k+=b();do L.cN&&(k+=""),B+=L.r,L=L.parent;while(L!=a.parent);return i.eE&&(k+=n(t)),M="",a.starts&&v(a.starts,""),i.rE?0:t.length}if(c(t,L))throw new Error('Illegal lexeme "'+t+'" for mode "'+(L.cN||"")+'"');return M+=t,t.length||1}var N=w(e);if(!N)throw new Error('Unknown language: "'+e+'"');s(N);var R,L=i||N,y={},k="";for(R=L;R!=N;R=R.parent)R.cN&&(k=h(R.cN,"",!0)+k);var M="",B=0;try{for(var C,j,I=0;;){if(L.t.lastIndex=I,C=L.t.exec(t),!C)break;j=m(t.substr(I,C.index-I),C[0]),I=C.index+j}for(m(t.substr(I)),R=L;R.parent;R=R.parent)R.cN&&(k+="");return{r:B,value:k,language:e,top:L}}catch(O){if(-1!=O.message.indexOf("Illegal"))return{r:0,value:n(t)};throw O}}function f(e,t){t=t||E.languages||Object.keys(x);var r={r:0,value:n(e)},a=r;return t.forEach(function(n){if(w(n)){var t=l(n,e,!1);t.language=n,t.r>a.r&&(a=t),t.r>r.r&&(a=r,r=t)}}),a.language&&(r.second_best=a),r}function g(e){return E.tabReplace&&(e=e.replace(/^((<[^>]+>|\t)+)/gm,function(e,n){return n.replace(/\t/g,E.tabReplace)})),E.useBR&&(e=e.replace(/\n/g,"
")),e}function h(e,n,t){var r=n?R[n]:t,a=[e.trim()];return e.match(/\bhljs\b/)||a.push("hljs"),-1===e.indexOf(r)&&a.push(r),a.join(" ").trim()}function p(e){var n=i(e);if(!a(n)){var t;E.useBR?(t=document.createElementNS("http://www.w3.org/1999/xhtml","div"),t.innerHTML=e.innerHTML.replace(/\n/g,"").replace(//g,"\n")):t=e;var r=t.textContent,o=n?l(n,r,!0):f(r),s=u(t);if(s.length){var p=document.createElementNS("http://www.w3.org/1999/xhtml","div");p.innerHTML=o.value,o.value=c(s,u(p),r)}o.value=g(o.value),e.innerHTML=o.value,e.className=h(e.className,n,o.language),e.result={language:o.language,re:o.r},o.second_best&&(e.second_best={language:o.second_best.language,re:o.second_best.r})}}function d(e){E=o(E,e)}function b(){if(!b.called){b.called=!0;var e=document.querySelectorAll("pre code");Array.prototype.forEach.call(e,p)}}function v(){addEventListener("DOMContentLoaded",b,!1),addEventListener("load",b,!1)}function m(n,t){var r=x[n]=t(e);r.aliases&&r.aliases.forEach(function(e){R[e]=n})}function N(){return Object.keys(x)}function w(e){return e=(e||"").toLowerCase(),x[e]||x[R[e]]}var E={classPrefix:"hljs-",tabReplace:null,useBR:!1,languages:void 0},x={},R={};return e.highlight=l,e.highlightAuto=f,e.fixMarkup=g,e.highlightBlock=p,e.configure=d,e.initHighlighting=b,e.initHighlightingOnLoad=v,e.registerLanguage=m,e.listLanguages=N,e.getLanguage=w,e.inherit=o,e.IR="[a-zA-Z]\\w*",e.UIR="[a-zA-Z_]\\w*",e.NR="\\b\\d+(\\.\\d+)?",e.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)",e.BNR="\\b(0b[01]+)",e.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~",e.BE={b:"\\\\[\\s\\S]",r:0},e.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[e.BE]},e.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[e.BE]},e.PWM={b:/\b(a|an|the|are|I|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|like)\b/},e.C=function(n,t,r){var a=e.inherit({cN:"comment",b:n,e:t,c:[]},r||{});return a.c.push(e.PWM),a.c.push({cN:"doctag",b:"(?:TODO|FIXME|NOTE|BUG|XXX):",r:0}),a},e.CLCM=e.C("//","$"),e.CBCM=e.C("/\\*","\\*/"),e.HCM=e.C("#","$"),e.NM={cN:"number",b:e.NR,r:0},e.CNM={cN:"number",b:e.CNR,r:0},e.BNM={cN:"number",b:e.BNR,r:0},e.CSSNM={cN:"number",b:e.NR+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",r:0},e.RM={cN:"regexp",b:/\//,e:/\/[gimuy]*/,i:/\n/,c:[e.BE,{b:/\[/,e:/\]/,r:0,c:[e.BE]}]},e.TM={cN:"title",b:e.IR,r:0},e.UTM={cN:"title",b:e.UIR,r:0},e});hljs.registerLanguage("sql",function(e){var t=e.C("--","$");return{cI:!0,i:/[<>{}*]/,c:[{cN:"operator",bK:"begin end start commit rollback savepoint lock alter create drop rename call delete do handler insert load replace select truncate update set show pragma grant merge describe use explain help declare prepare execute deallocate release unlock purge reset change stop analyze cache flush optimize repair kill install uninstall checksum restore check backup revoke",e:/;/,eW:!0,k:{keyword:"abort abs absolute acc acce accep accept access accessed accessible account acos action activate add addtime admin administer advanced advise aes_decrypt aes_encrypt after agent aggregate ali alia alias allocate allow alter always analyze ancillary and any anydata anydataset anyschema anytype apply archive archived archivelog are as asc ascii asin assembly assertion associate asynchronous at atan atn2 attr attri attrib attribu attribut attribute attributes audit authenticated authentication authid authors auto autoallocate autodblink autoextend automatic availability avg backup badfile basicfile before begin beginning benchmark between bfile bfile_base big bigfile bin binary_double binary_float binlog bit_and bit_count bit_length bit_or bit_xor bitmap blob_base block blocksize body both bound buffer_cache buffer_pool build bulk by byte byteordermark bytes c cache caching call calling cancel capacity cascade cascaded case cast catalog category ceil ceiling chain change changed char_base char_length character_length characters characterset charindex charset charsetform charsetid check checksum checksum_agg child choose chr chunk class cleanup clear client clob clob_base clone close cluster_id cluster_probability cluster_set clustering coalesce coercibility col collate collation collect colu colum column column_value columns columns_updated comment commit compact compatibility compiled complete composite_limit compound compress compute concat concat_ws concurrent confirm conn connec connect connect_by_iscycle connect_by_isleaf connect_by_root connect_time connection consider consistent constant constraint constraints constructor container content contents context contributors controlfile conv convert convert_tz corr corr_k corr_s corresponding corruption cos cost count count_big counted covar_pop covar_samp cpu_per_call cpu_per_session crc32 create creation critical cross cube cume_dist curdate current current_date current_time current_timestamp current_user cursor curtime customdatum cycle d data database databases datafile datafiles datalength date_add date_cache date_format date_sub dateadd datediff datefromparts datename datepart datetime2fromparts day day_to_second dayname dayofmonth dayofweek dayofyear days db_role_change dbtimezone ddl deallocate declare decode decompose decrement decrypt deduplicate def defa defau defaul default defaults deferred defi defin define degrees delayed delegate delete delete_all delimited demand dense_rank depth dequeue des_decrypt des_encrypt des_key_file desc descr descri describ describe descriptor deterministic diagnostics difference dimension direct_load directory disable disable_all disallow disassociate discardfile disconnect diskgroup distinct distinctrow distribute distributed div do document domain dotnet double downgrade drop dumpfile duplicate duration e each edition editionable editions element ellipsis else elsif elt empty enable enable_all enclosed encode encoding encrypt end end-exec endian enforced engine engines enqueue enterprise entityescaping eomonth error errors escaped evalname evaluate event eventdata events except exception exceptions exchange exclude excluding execu execut execute exempt exists exit exp expire explain export export_set extended extent external external_1 external_2 externally extract f failed failed_login_attempts failover failure far fast feature_set feature_value fetch field fields file file_name_convert filesystem_like_logging final finish first first_value fixed flash_cache flashback floor flush following follows for forall force form forma format found found_rows freelist freelists freepools fresh from from_base64 from_days ftp full function g general generated get get_format get_lock getdate getutcdate global global_name globally go goto grant grants greatest group group_concat group_id grouping grouping_id groups gtid_subtract guarantee guard handler hash hashkeys having hea head headi headin heading heap help hex hierarchy high high_priority hosts hour http i id ident_current ident_incr ident_seed identified identity idle_time if ifnull ignore iif ilike ilm immediate import in include including increment index indexes indexing indextype indicator indices inet6_aton inet6_ntoa inet_aton inet_ntoa infile initial initialized initially initrans inmemory inner innodb input insert install instance instantiable instr interface interleaved intersect into invalidate invisible is is_free_lock is_ipv4 is_ipv4_compat is_not is_not_null is_used_lock isdate isnull isolation iterate java join json json_exists k keep keep_duplicates key keys kill l language large last last_day last_insert_id last_value lax lcase lead leading least leaves left len lenght length less level levels library like like2 like4 likec limit lines link list listagg little ln load load_file lob lobs local localtime localtimestamp locate locator lock locked log log10 log2 logfile logfiles logging logical logical_reads_per_call logoff logon logs long loop low low_priority lower lpad lrtrim ltrim m main make_set makedate maketime managed management manual map mapping mask master master_pos_wait match matched materialized max maxextents maximize maxinstances maxlen maxlogfiles maxloghistory maxlogmembers maxsize maxtrans md5 measures median medium member memcompress memory merge microsecond mid migration min minextents minimum mining minus minute minvalue missing mod mode model modification modify module monitoring month months mount move movement multiset mutex n name name_const names nan national native natural nav nchar nclob nested never new newline next nextval no no_write_to_binlog noarchivelog noaudit nobadfile nocheck nocompress nocopy nocycle nodelay nodiscardfile noentityescaping noguarantee nokeep nologfile nomapping nomaxvalue nominimize nominvalue nomonitoring none noneditionable nonschema noorder nopr nopro noprom nopromp noprompt norely noresetlogs noreverse normal norowdependencies noschemacheck noswitch not nothing notice notrim novalidate now nowait nth_value nullif nulls num numb numbe nvarchar nvarchar2 object ocicoll ocidate ocidatetime ociduration ociinterval ociloblocator ocinumber ociref ocirefcursor ocirowid ocistring ocitype oct octet_length of off offline offset oid oidindex old on online only opaque open operations operator optimal optimize option optionally or oracle oracle_date oradata ord ordaudio orddicom orddoc order ordimage ordinality ordvideo organization orlany orlvary out outer outfile outline output over overflow overriding p package pad parallel parallel_enable parameters parent parse partial partition partitions pascal passing password password_grace_time password_lock_time password_reuse_max password_reuse_time password_verify_function patch path patindex pctincrease pctthreshold pctused pctversion percent percent_rank percentile_cont percentile_disc performance period period_add period_diff permanent physical pi pipe pipelined pivot pluggable plugin policy position post_transaction pow power pragma prebuilt precedes preceding precision prediction prediction_cost prediction_details prediction_probability prediction_set prepare present preserve prior priority private private_sga privileges procedural procedure procedure_analyze processlist profiles project prompt protection public publishingservername purge quarter query quick quiesce quota quotename radians raise rand range rank raw read reads readsize rebuild record records recover recovery recursive recycle redo reduced ref reference referenced references referencing refresh regexp_like register regr_avgx regr_avgy regr_count regr_intercept regr_r2 regr_slope regr_sxx regr_sxy reject rekey relational relative relaylog release release_lock relies_on relocate rely rem remainder rename repair repeat replace replicate replication required reset resetlogs resize resource respect restore restricted result result_cache resumable resume retention return returning returns reuse reverse revoke right rlike role roles rollback rolling rollup round row row_count rowdependencies rowid rownum rows rtrim rules safe salt sample save savepoint sb1 sb2 sb4 scan schema schemacheck scn scope scroll sdo_georaster sdo_topo_geometry search sec_to_time second section securefile security seed segment select self sequence sequential serializable server servererror session session_user sessions_per_user set sets settings sha sha1 sha2 share shared shared_pool short show shrink shutdown si_averagecolor si_colorhistogram si_featurelist si_positionalcolor si_stillimage si_texture siblings sid sign sin size size_t sizes skip slave sleep smalldatetimefromparts smallfile snapshot some soname sort soundex source space sparse spfile split sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_small_result sql_variant_property sqlcode sqldata sqlerror sqlname sqlstate sqrt square standalone standby start starting startup statement static statistics stats_binomial_test stats_crosstab stats_ks_test stats_mode stats_mw_test stats_one_way_anova stats_t_test_ stats_t_test_indep stats_t_test_one stats_t_test_paired stats_wsr_test status std stddev stddev_pop stddev_samp stdev stop storage store stored str str_to_date straight_join strcmp strict string struct stuff style subdate subpartition subpartitions substitutable substr substring subtime subtring_index subtype success sum suspend switch switchoffset switchover sync synchronous synonym sys sys_xmlagg sysasm sysaux sysdate sysdatetimeoffset sysdba sysoper system system_user sysutcdatetime t table tables tablespace tan tdo template temporary terminated tertiary_weights test than then thread through tier ties time time_format time_zone timediff timefromparts timeout timestamp timestampadd timestampdiff timezone_abbr timezone_minute timezone_region to to_base64 to_date to_days to_seconds todatetimeoffset trace tracking transaction transactional translate translation treat trigger trigger_nestlevel triggers trim truncate try_cast try_convert try_parse type ub1 ub2 ub4 ucase unarchived unbounded uncompress under undo unhex unicode uniform uninstall union unique unix_timestamp unknown unlimited unlock unpivot unrecoverable unsafe unsigned until untrusted unusable unused update updated upgrade upped upper upsert url urowid usable usage use use_stored_outlines user user_data user_resources users using utc_date utc_timestamp uuid uuid_short validate validate_password_strength validation valist value values var var_samp varcharc vari varia variab variabl variable variables variance varp varraw varrawc varray verify version versions view virtual visible void wait wallet warning warnings week weekday weekofyear wellformed when whene whenev wheneve whenever where while whitespace with within without work wrapped xdb xml xmlagg xmlattributes xmlcast xmlcolattval xmlelement xmlexists xmlforest xmlindex xmlnamespaces xmlpi xmlquery xmlroot xmlschema xmlserialize xmltable xmltype xor year year_to_month years yearweek",literal:"true false null",built_in:"array bigint binary bit blob boolean char character date dec decimal float int int8 integer interval number numeric real record serial serial8 smallint text varchar varying void"},c:[{cN:"string",b:"'",e:"'",c:[e.BE,{b:"''"}]},{cN:"string",b:'"',e:'"',c:[e.BE,{b:'""'}]},{cN:"string",b:"`",e:"`",c:[e.BE]},e.CNM,e.CBCM,t]},e.CBCM,t]}}); \ No newline at end of file