PageSourceSearch

http://www.jooq.org/js/jooq.js

js jooq.org collected 2026-10-02 04:01:12 UTC 17,322 bytes, 464 lines download raw bytes

1$(document).ready(function() {
2    var $registration = $('#registration'),
3        $save = $('.save'),
4        $email = $('#email'),
5        $survey = $('#survey'),
6        $noThanks = $('.no-thanks'),
7
8        random = function() {
9            return Math.random() * 5000 + 8000;
10        },
11
12        track = function(url) {
13            var tracker;
14
15            try {
16                tracker = _gat._getTracker("UA-30716479-1");
17                 
18                if (('' + url).substring(0, 4) === 'http')
19                    tracker._trackPageview('/external/' + url.replace(/^https?\:\/\//i, ""));
20                else
21                    tracker._trackPageview('/event/' + url);
22            }
23            catch (ignore) {}
24        },
25
26        fade = function($element) {
27            var heightBefore = $element.css('height'),
28                heightAfter;
29
30            $element.html("Thank you!");
31            heightAfter = $element.css('height');
32
33            $element.css('height', heightBefore);
34            $element.animate({
35                height: heightAfter
36            }, {
37                duration: 500,
38                complete: function() {
39                    $element.fadeOut(1000, function() {
40                        if (!$email.is(':visible') && !$survey.is(':visible')) {
41                            $.modal.close();
42                        }
43                    });
44                }
45            });
46        },
47
48        registration = function(forceEmail, forceSurvey) {
49            $email.show();
50            $survey.show();
51            $registration.modal();
52        };
53
54    $save.click(function() {
55        track('email/clicked');
56        $.ajax({
57            type: "POST",
58            url: '/registration-email-save',
59            data: $(".registration-email-form:visible").serialize(),
60            success: function(data, textStatus, jqXHR) {
61                fade($email);
62            }
63        });
64
65        return false;
66    });
67
68    $survey.click(function() {
69        track('survey/clicked');
70        fade($survey);
71        window.open('http://srvy.it/15yxTuO');
72    });
73
74    $noThanks.click(function() {
75        var $this = $(this);
76        track($this.data("fade") + '/no-thanks');
77        fade($('#' + $this.data("fade")));
78
79        return false;
80    });
81
82    $('.action, .hoverable').hover(
83        function() {
84            var $this = $(this);
85            
86            if (!$this.data('originalBackgroundColor')) {
87                $this.data('originalBackgroundColor', $this.css('backgroundColor'));
88                $this.animate({
89                    backgroundColor: $.Color($this.css('backgroundColor')).transition('#eee', 0.5)
90                });
91            }
92        },
93        function() {
94            var $this = $(this);
95            
96            $this.animate({
97                backgroundColor: $this.data('originalBackgroundColor')
98            }, {
99                complete: function() {
100                    $this.removeData('originalBackgroundColor');
101                }
102            });
103        }
104    );
105
106    if (!$("html").hasClass("too-old")) {
107        $('.action-switch').click(function() {
108            var $this = $(this);
109            var sw = $this.data('switch'),
110                swWith = $this.data('switchWith');
111
112            if (!sw) {
113                sw = $this.attr('id');
114            }
115
116            $('#' + sw).hide({
117                effect: 'drop',
118                direction: 'left',
119                duration: 200,
120                complete: function() {
121                    $.bbq.pushState({a : swWith});
122
123                    $('#' + swWith).show({
124                        effect: 'drop',
125                        direction: 'right',
126                        duration: 200
127                    });
128                }
129            });
130        });
131    }
132
133    if ($("html").hasClass("too-old")) {
134        $('img')
135            .each(function() {
136                this.src = this.src.replace(".svg", ".png")
137            });
138
139        // IE8 and earlier can't seem to do the above fancy animations nicely
140        $('.subscriptions').show();
141    }
142
143    $('.rotate-children')
144        .each(function() {
145            var $container = $(this),
146                $children = $container.children("div"),
147                i = 0,
148                rotate = function() {
149                    setTimeout(function() {
150                        $($children[i]).fadeOut(
151                            "normal",
152                            function() {
153                                $($children[++i % $children.length]).fadeIn();
154                                rotate();
155                            }
156                        );
157                    }, random())
158                };
159
160            rotate();
161        });
162
163    (function() {
164        var $tooltip = $('#manual-code-tooltip'),
165            entered,
166            show = function($pre) {
167                return function(event) {
168                    var x = $pre.offset().left + $pre.outerWidth() - $tooltip.outerWidth(),
169                        y = $pre.offset().top + $pre.outerHeight() - $tooltip.outerHeight(),
170                        $a = $tooltip.find("a"),
171                        version = document.location.href.replace(/.*\/doc\/(.*?)\/.*/, "$1");
172
173                    entered = $pre;
174                    $a.attr("href", $a.attr("href").replace(/latest/, version));
175                    $tooltip.css({top: y, left: x, position: 'absolute', zIndex: 2}).show();
176                }
177            },
178            hide = function($pre) {
179                return function() {
180                    if (entered == $pre)
181                        setTimeout(function() {
182                        }, 1000);
183                }
184            };
185
186        if (document.location.href.indexOf("manual") > 0)
187            $('pre.prettyprint').each(function(index, pre) {
188                var $pre = $(pre);
189
190                $pre.bind({
191                    mouseenter: show($pre),
192                    mouseleave: hide($pre)
193                });
194            });
195
196        $(window).resize(function() {
197            if (entered)
198                show(entered)();
199        })
200    })();
201
202    $('a').filter("[href*='http'],[href$='.pdf']")
203          .filter(":not([href*='jooq.org']),[href$='.pdf']")
204          .click(function() {
205            var $this = $(this);
206            $this.attr('target', '_blank');
207            $this.attr('rel', 'noopener noreferrer');
208            track($(this).attr('href'));
209          });
210    
211    $('a.license-link').click(function() {
212        var $this = $(this),
213            $license;
214            
215        if ($this.data('type') == 'oss')
216            $license = $('#oss-license');
217        else if ($this.data('type') == 'trial')
218            $license = $('#trial-license');
219        else if ($this.data('type') == 'trial-java-17')
220            $license = $('#trial-license');
221        else if ($this.data('type') == 'trial-java-11')
222            $license = $('#trial-license');
223        else if ($this.data('type') == 'trial-java-8')
224            $license = $('#trial-license');
225        else if ($this.data('type') == 'trial-java-6')
226            $license = $('#trial-license');
227        else
228            $license = $('#full-license');
229
230        // Some scope issues...?
231        $('button.agree').data('href', $this.data('href'));
232        $('button.agree').data('type', $this.data('type'));
233        $license.modal();
234        return false;
235    });
236
237    $('button.agree').click(function() {
238        var $this = $(this);
239
240        setTimeout(function() {
241            setTimeout(function() {
242                document.location.href = '/download/license-accepted' +
243                '?type=' + $this.data('type') +
244                '&file=' + $this.data('href');
245            }, 200);
246
247            $.modal.close();
248        }, 200);
249    });
250
251    $('button.disagree').click(function() {
252        $.modal.close();
253    });
254    
255    $('a.agree-link').click(function() {
256        var read = $(this).data('read');
257        
258        if (read === 'license')
259            $.cookie('read-license', 'true', { path: '/' });
260    });
261
262    $("#newsletterbutton, .newsletterbutton").click(function() {
263        registration(true, true);
264    });
265    
266    $('#registration-teaser-ok').click(function() {
267		$.cookie('jooq-registration-teaser', 'clicked', { path: '/' });
268        $('#registration-teaser').fadeOut(600);
269
270    	registration(true, true);
271    });
272      
273    $('#registration-teaser-no').click(function() {
274		$.cookie('jooq-registration-teaser', 'no-thanks', { path: '/' });
275        $('#registration-teaser').fadeOut(600);
276
277    	track('registration-teaser/no-thanks');
278    });
279
280    $(window).trigger('hashchange');
281    
282    // This seems to break sometimes
283    $('form.validate').validate();    
284
285    if (document.location.href.indexOf("manual") != -1) {
286        $("pre.lang-java").each(function() {
287            var $pre = $(this),
288                id = $pre.attr("id");
289
290            if ($pre.html().indexOf("import ") === -1) {
291                if (!id)
292                    id = "id-" + (globalToggleId++);
293
294                $pre.attr("id", id);
295                $("body").append('<div id="toggle-' + id + '" style="top: 0; left: 0; position: absolute; z-index: 2;" class="tooltip show-imports"><a href="javascript:toggleImports(\'' + id + '\');">&#xFF0B; show imports</a></div>');
296            }
297        });
298
299        updatedTogglePositions();
300        $(window).resize(updatedTogglePositions);
301        $(window).scroll(updatedTogglePositions);
302    }
303
304    $(".tab").click(function() {
305        var $this = $(this),
306            $wrapper = $(".tabs[data-name='" + $this.data("name") + "']"),
307            $tabs = $(".tab[data-name='" + $this.data("name") + "']"),
308            $activeTabs = $tabs.filter(".active"),
309            $inactiveTabs = $tabs.filter("[data-value='" + $this.data("value") + "']"),
310            $tabContents = $(".tab-content[data-name='" + $this.data("name") + "']"),
311            $activeTabContents = $tabContents.filter(".active"),
312            $inactiveTabContents = $tabContents.filter("[data-value='" + $this.data("value") + "']");
313    
314        if ($this.hasClass("inactive")) {
315            $activeTabs.removeClass("active").addClass("inactive");
316            $activeTabContents.removeClass("active").addClass("inactive");
317            $inactiveTabs.removeClass("inactive").addClass("active");
318            $inactiveTabContents.removeClass("inactive").addClass("active");
319    
320            if ($wrapper.data("sticky"))
321                $.cookie("manual-tab-" + $this.data("name"), $this.data("value"), { "path" : "/" });
322    
323            updatedTogglePositions();
324        }
325    });
326
327    if (window['switchLicense'])
328        switchLicense();
329});
330
331globalToggleId = 1;
332function updatedTogglePositions() {
333    let $toggle = $("div.show-imports");
334    let visibleOrClose = function(e) {
335        let $e = jQuery(e);
336        let $window = jQuery(window);
337
338        let etop = $e.offset().top;
339        let ebottom = etop + $e.outerHeight();
340
341        let vtop = $window.scrollTop();
342        let vbottom = vtop + $window.height();
343
344        return (ebottom + 3000) > vtop && (etop - 3000) < vbottom;
345    };
346
347    $toggle.each(function() {
348        var $this = $(this),
349            $pre = $('#' + $this.attr("id").replace('toggle-', '')),
350            position = $pre.position(),
351            top = position.top - 10,
352            left = position.left + /* $pre.width() - $this.width() + */ 20;
353
354        if (visibleOrClose($pre))
355            $this.css("top", top + "px").css("left", left + "px").show();
356        else
357            $this.hide();
358    });
359}
360
361function toggleImports(id) {
362    var $toggle = $('#toggle-' + id + ' a'),
363        $pre = $('#' + id),
364        text = $pre.text(),
365        prepend = '';
366  
367    if ($toggle.html().indexOf('show') !== -1) {
368        $toggle.html('&#xFF0D; hide imports');
369  
370        prepend += '<span class="imports">';
371        prepend += '<span class="com">// For more info on imports and data types, click on the "Help" icon\n</span>'
372        prepend += '<span class="com">// These imports, and possibly others, are implied:\n</span>';
373
374
375        if (/\b(Blob|Clob|Connection|DatabaseMetaData|DataSource|DriverManager|NClob|(Callable|Prepared)?Statement|ResultSet(MetaData)?|Savepoint|SQLData|SQLInput|SQLOutput|SQLXML|Struct|Wrapper)\b/.test(text))
376            prepend += '<span class="kwd">import</span><span class="pln"> java.sql.*;\n</span>'
377                    + '<span class="kwd">import</span><span class="pln"> javax.sql.*;\n</span>';
378    
379        if (/@(Basic|Column|ColumnResult|ConstructorResult|Converter|Embeddable|Embedded|EmbeddedId|Entity|EntityResult|FieldResult|ForeignKey|GeneratedValue|Id|IdClass|Index|JoinColumn|JoinColumns|JoinTable|ManyToMany|ManyToOne|OneToMany|OneToOne|Table|UniqueConstraint)\b/.test(text))
380            if (Number(document.location.href.match(/\/3\.(\d+)\//)[1]) > 15)
381                prepend += '<span class="kwd">import</span><span class="pln"> jakarta.persistence.*;\n</span>';
382            else
383                prepend += '<span class="kwd">import</span><span class="pln"> javax.persistence.*;\n</span>';
384
385        if (/org\.jooq\.meta\.jaxb\.Configuration/.test(text) || /.*myConfigurationName.*/.test(text))
386            prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.meta.jaxb.*;\n</span>';
387        else if (/org\.jooq\.util\.jaxb\.Configuration/.test(text))
388            prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.util.jaxb.*;\n</span>';
389
390        if (/\b((ACCESS|ASE|AURORA_MYSQL|AURORA_POSTGRES|COCKROACHDB|DB2|DERBY|FIREBIRD|H2|HANA|HSQLDB|INFORMIX|INGRES|MARIADB|MEMSQL|MYSQL|ORACLE|POSTGRES|REDSHIFT|SQLDATAWAREHOUSE|SQLITE|SQLSERVER|SYBASE|TERADATA|VERTICA)[_A-Z0-9]*)\b/.test(text))
391            prepend += '<span class="kwd">import static</span><span class="pln"> org.jooq.SQLDialect.*;\n</span>';
392
393        if (/(^|[^\.])\b\w+\b\(/.test(text))
394            prepend += '<span class="kwd">import static</span><span class="pln"> org.jooq.impl.DSL.*;\n</span>';
395
396        if (/\b(BIGINT|BIGINTUNSIGNED|BINARY|BIT|BLOB|BOOLEAN|CHAR|CLOB|DATE|DECIMAL|DECIMAL_INTEGER|DOUBLE|FLOAT|INSTANT|INTEGER|INTEGERUNSIGNED|INTERVAL|INTERVALDAYTOSECOND|INTERVALYEARTOMONTH|JSON|JSONB|LOCALDATE|LOCALDATETIME|LOCALTIME|LONGNVARCHAR|LONGVARBINARY|LONGVARCHAR|NCHAR|NCLOB|NUMERIC|NVARCHAR|OFFSETDATETIME|OFFSETTIME|OTHER|REAL|RECORD|RESULT|ROWID|SMALLINT|SMALLINTUNSIGNED|TIME|TIMESTAMP|TIMESTAMPWITHTIMEZONE|TIMEWITHTIMEZONE|TINYINT|TINYINTUNSIGNED|UUID|VARBINARY|VARCHAR|XML)\b/.test(text))
397            prepend += '<span class="kwd">import static</span><span class="pln"> org.jooq.impl.SQLDataType.*;\n</span>';
398
399        if (/\bjson\(/.test(text))
400            prepend += '<span class="kwd">import static</span><span class="pln"> org.jooq.JSON.json;\n</span>';
401        if (/\bjsonb\(/.test(text))
402            prepend += '<span class="kwd">import static</span><span class="pln"> org.jooq.JSONB.jsonb;\n</span>';
403
404        if (/\b(AUTHOR|BOOK(_STORE|_TO_BOOK_STORE)?|LANGUAGE)\b/.test(text))
405            prepend += '<span class="kwd">import static</span><span class="pln"> com.example.generated.Tables.*;\n</span>';
406        
407        prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.*;\n</span>';
408
409        if (/JSON.valueOf/.test(text))
410            prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.JSON;\n</span>';
411        if (/JSONB.valueOf/.test(text))
412            prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.JSONB;\n</span>';
413        if (/XML.valueOf/.test(text))
414            prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.XML;\n</span>';
415
416        if (/\bRecord\b/.test(text))
417            prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.Record;</span><span class="com"> // Starting with Java 14, Record can not be imported on demand anymore\n</span>';
418    
419        if (/\bSettings\b/.test(text))
420            prepend += '<span class="kwd">
420import</span><span class="pln"> org.jooq.conf.*;\n</span>';
421
422        prepend += '<span class="kwd">import</span><span class="pln"> org.jooq.impl.*;\n\n</span>';
423
424        if ((text.indexOf("create.") !== -1))
425            prepend += '<span class="com">// The "create" reference is an instance of <a href="https://www.jooq.org/javadoc/latest/org.jooq/org/jooq/DSLContext.html">DSLContext</a>\n\n</span>';
426
427        prepend += '</span>';
428
429        $pre.prepend(prepend);
430    }
431    else {
432        $toggle.html('&#xFF0B; show imports');
433        $('#' + id + " span.imports").remove();
434    } 
435
436    updatedTogglePositions();
437}
438
439$(window).bind('hashchange', function(e) {
440    var id = $.bbq.getState('a'),
441        hideAll = function() {
442            $('.action-switch').each(function() {
443                var $this = $(this);
444                var sw = $this.data('switch'),
445                    swWith = $this.data('switchWith');
446            
447                if (!sw) {
448                    sw = $this.attr('id');
449                }
450                
451                $('#' + sw).hide();
452                $('#' + swWith).hide();
453            });
454        };
455
456    if (!id) {
457        hideAll();
458        $('.action-default').show();
459    }
460    else if ($('#' + id).is(':not(:visible)')) {
461        hideAll();
462        $('#' + id).show();
463    }
464});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.