From 57d9cd19db6a287b960b399a0d1ad8f92e79dc1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Aasted=20S=C3=B8rensen?= Date: Thu, 19 Jan 2017 21:36:34 +0100 Subject: [PATCH 1/2] Create Gulp build script for minification. --- .gitignore | 1 + bookmarklet.min.js | 1 - gulpfile.js | 22 ++++++++++++++++++++++ jdocenhance.min.js | 1 - bookmarklet.js => src/bookmarklet.js | 0 jdocenhance.js => src/jdocenhance.js | 0 6 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .gitignore delete mode 100644 bookmarklet.min.js create mode 100644 gulpfile.js delete mode 100644 jdocenhance.min.js rename bookmarklet.js => src/bookmarklet.js (100%) rename jdocenhance.js => src/jdocenhance.js (100%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..838458f --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/dist/ \ No newline at end of file diff --git a/bookmarklet.min.js b/bookmarklet.min.js deleted file mode 100644 index ea1fb76..0000000 --- a/bookmarklet.min.js +++ /dev/null @@ -1 +0,0 @@ -javascript:(function(){function a(a,e){var n=document.createElement("script");n.src=a,n.onload=e,document.getElementsByTagName("head")[0].appendChild(n)}a("//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js",function(){a("//cdn.rawgit.com/haasted/Javadoc-Enhancer/e9a0e7f8f165b2f26c4dddb6efa3d1849c666ba8/jdocenhance.min.js")})})(); \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js new file mode 100644 index 0000000..13b51d7 --- /dev/null +++ b/gulpfile.js @@ -0,0 +1,22 @@ +var gulp = require('gulp'), + minify = require('gulp-minify'), + del = require('del'); + + +gulp.task('default', ['clean', 'minify']); + +gulp.task('minify', function() { + gulp.src('src/jdocenhance.js') + .pipe(minify({})) + .pipe(gulp.dest('dist')); + + gulp.src('src/bookmarklet.js') + .pipe(minify({})) + .pipe(gulp.dest('dist')); +}); + +gulp.task('clean', function() { + return del( + ['dist/*'] + ); +}); \ No newline at end of file diff --git a/jdocenhance.min.js b/jdocenhance.min.js deleted file mode 100644 index 686411d..0000000 --- a/jdocenhance.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(){function e(){clearTimeout(o);var e=$("#classSearch",d).val();$(c,d).removeClass("filtered");var n=e.match(/([A-Z]{1}[a-z]*|\*|[a-z]+)/);if(null===n||"*"===e.trim())return void $(c,d).removeClass("filtered");if(n=n[0],"*"===n){var i=r(e);return void a($(c,d),i)}if(n===e)return void t(n);t(n);var i=r(e);a($(c+":not(.filtered)",d),i)}function t(e){var t=n(e,$(c,d)),a=i(e,$(c,d));if(-1==t||-1==a)return void $(c,d).addClass("filtered");var r=$(c,d).eq(t);r.prevAll().addClass("filtered");var l=$(c,d).eq(a);l.nextAll().addClass("filtered")}function a(e,t){e.each(function(e,a){a=$(a),a.toggleClass("filtered",null===a.text().match(t))})}function r(e){var t="",a=!1;return $.each(e.split(""),function(e,r){isNaN(r)?"*"==r?t+=".*":"?"==r?t+=".":"."==r?t+="\\.":r==r.toUpperCase()?(a=!0,t+=0==e?"^"+r:"[a-z0-9]+"+r):t+=r:t+=r}),a?new RegExp(t):new RegExp(t,"i")}function n(e,t){var a=function(e,t,r,n){if(r>n)return-1;var i=Math.floor((r+n)/2),l=$(t[i]).text().substr(0,e.length).toLowerCase();if(l>e)return a(e,t,r,i-1);if(e>l)return a(e,t,i+1,n);var s=$(t[i-1]).text().toLowerCase();return 0===s.indexOf(e)?a(e,t,r,i-1):i};return a(e.toLowerCase(),t,0,t.size())}function i(e,t){var a=function(e,t,r,n){if(r>n)return-1;var i=Math.floor((r+n)/2),l=$(t[i]).text().substr(0,e.length).toLowerCase();if(l>e)return a(e,t,r,i-1);if(e>l)return a(e,t,i+1,n);var s=$(t[i+1]).text().toLowerCase();return 0===s.indexOf(e)?a(e,t,i+1,n):i};return a(e.toLowerCase(),t,0,t.size())}function l(){var e,t=$("#classSearch",d).data("selectedindex");e=t?$("a:visible",d).eq(t):$("a:visible:first",d),f.location.replace(e.attr("href"))}function s(e){var t=$("#classSearch",d).data("selectedindex");if(t||(t=0),!(0>t+e)){var a=$("a:visible",d).eq(t+e);0!=a.length&&(a.addClass("selected"),$("a:visible",d).eq(t).removeClass("selected"),$("#classSearch",d).data("selectedindex",t+e))}}var o,c,d=top.frames.packageFrame.document,f=top.frames.classFrame.document,u=$("div.indexContainer",d);0==u.length&&(u=$("body",d)),u.prepend('
'),$("html > head",d).append(""),$("html > head",d).append(""),$("#classSearch",d).keyup(function(e){13==e.keyCode?l():40==e.keyCode?s(1):38==e.keyCode&&s(-1)}),$("li",d).length>10?c="li":($("a",d).each(function(e,t){$(t).next().andSelf().wrapAll("")}),c="span"),$("#classSearch",d).keyup(function(t){clearTimeout(o),o=setTimeout(e,250)})}(); \ No newline at end of file diff --git a/bookmarklet.js b/src/bookmarklet.js similarity index 100% rename from bookmarklet.js rename to src/bookmarklet.js diff --git a/jdocenhance.js b/src/jdocenhance.js similarity index 100% rename from jdocenhance.js rename to src/jdocenhance.js From 36399d1d4d3505a1851ba0378a5600577bdd3760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Aasted=20S=C3=B8rensen?= Date: Sun, 29 Jan 2017 15:20:12 +0100 Subject: [PATCH 2/2] Add package.json. Strip console.log during minification. --- .gitignore | 3 ++- gulpfile.js | 6 ++++-- package.json | 30 ++++++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 838458f..81ce55f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -/dist/ \ No newline at end of file +/dist/ +/node_modules/ \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 13b51d7..31e5e4d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,16 +1,18 @@ var gulp = require('gulp'), minify = require('gulp-minify'), - del = require('del'); - + del = require('del'), + stripDebug = require('gulp-strip-debug'); gulp.task('default', ['clean', 'minify']); gulp.task('minify', function() { gulp.src('src/jdocenhance.js') + .pipe(stripDebug()) .pipe(minify({})) .pipe(gulp.dest('dist')); gulp.src('src/bookmarklet.js') + .pipe(stripDebug()) .pipe(minify({})) .pipe(gulp.dest('dist')); }); diff --git a/package.json b/package.json new file mode 100644 index 0000000..d3bab89 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "javadoc-enhancer", + "version": "1.0.0", + "description": "Javadoc-Enhander adds a powerful search-field to the class list of Javadoc page. The search field allows the use of wildcards and mimics the camel-case notation used for navigating classes in tools such as IntelliJ IDEA and Eclipse.", + "main": "gulpfile.js", + "scripts": { + "test": "test" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/haasted/Javadoc-Enhancer.git" + }, + "keywords": [ + "java", + "javadoc", + "bookmarklet" + ], + "author": "Henrik Aasted Sørensen ", + "license": "MIT", + "bugs": { + "url": "https://github.com/haasted/Javadoc-Enhancer/issues" + }, + "homepage": "https://github.com/haasted/Javadoc-Enhancer#readme", + "devDependencies": { + "del": "^2.2.2", + "gulp": "^3.9.1", + "gulp-minify": "0.0.14", + "gulp-strip-debug" : "1.1.0" + } +}