123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- ---
- ---
- function submitJiraSearchForm() {
- var queryTemplate1 = '(summary ~ "%1" OR description ~ "%1" OR comment ~ "%1") AND ';
- var queryTemplate2 = 'project = CB AND resolution = Unresolved %2ORDER BY created';
- var componentKeywords = [
- /\b(ios|iphone|ipad|ipod)\b/ig, 'iOS',
- /\b(android)\b/ig, 'Android',
- /\b(blackberry|rim|bb.?|bb10|webworks)\b/ig, 'BlackBerry',
- /\b(webos)\b/ig, 'webOS',
- /\b(wp7|windows phone)\b/ig, 'WP7',
- /\b(wp8|windows phone)\b/ig, 'WP8'
- ];
- var query = document.getElementById('jira-search-box').value;
-
- var components = [];
- for (var i = 0; i < componentKeywords.length; i += 2) {
- if (query.match(componentKeywords[i])) {
- query = query.replace(componentKeywords[i], '');
- components.push(componentKeywords[i + 1]);
- }
- }
- var componentsQuery = '';
- if (components.length) {
-
- components.push('Docs', 'mobile-spec', 'CordovaJS');
- componentsQuery = 'AND component in (' + components.join(', ') + ') ';
- }
-
- query = query.replace(/"/g, '');
- var tokens = query.split(/\s+/);
- query = '';
- for (var i = 0; i < tokens.length; ++i) {
- if (tokens[i]) {
- query += queryTemplate1.replace(/%1/g, tokens[i]);
- }
- }
- query += queryTemplate2.replace('%2', componentsQuery)
- window.open('https://issues.apache.org/jira/secure/IssueNavigator.jspa?mode=show&reset=true&navType=simple&jqlQuery=' + encodeURIComponent(query), '_newtab' + new Date);
- }
- function setCookie(cname, cvalue, exdays) {
- var d = new Date();
- d.setTime(d.getTime() + (exdays*24*60*60*1000));
- var expires = "expires="+d.toUTCString();
- document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/";
- }
- function getCookie(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(';');
- for(var i=0; i<ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0)==' ') c = c.substring(1);
- if (c.indexOf(name) == 0) return c.substring(name.length,c.length);
- }
- return "";
- }
- var lastVisit = getCookie("visitTime");
- function checkNotification() {
- var dates = [];
- if (lastVisit != "") {
- {% for post in site.posts %}
- dates.push('{{ post.date | date_to_rfc822 }}');{% endfor %}
- }
- var new_blog_count = 0;
- for(var i = 0; i < dates.length ; i++) {
- var blog_time = new Date(dates[i]).getTime();
- if(blog_time > lastVisit) {
- new_blog_count++;
- }
- else {
- break;
- }
- }
- return new_blog_count;
- }
- $(document).ready(function () {
-
- $('.adorner').each(function(i) {
- var blog_time = new Date($(this).attr('blogTime')).getTime();
- if(lastVisit != "" && blog_time > lastVisit) {
- this.style.backgroundColor = "#3992ab";
- }
- });
- var new_blog_count = checkNotification();
- if (new_blog_count) {
- document.getElementById("new_blog_count").innerHTML = new_blog_count;
- }
-
- var client = new ZeroClipboard();
- client.on("ready", function(e) {
- var copyButtons = document.getElementsByClassName("btn-copy");
- for(var i = 0; i < copyButtons.length; i++) {
- client.clip(copyButtons[i]);
- }
- });
-
- client.on("error", function(e) {
- var copyButtons = document.getElementsByClassName("btn-copy");
- for(var i = 0; i < copyButtons.length; i++) {
- copyButtons[i].addEventListener("click", function(clickEvent) {
- var id = clickEvent.target.getAttribute("data-clipboard-target");
- var range = document.createRange();
- range.selectNode(document.getElementById(id));
- var select = window.getSelection();
- select.removeAllRanges();
- select.addRange(range);
- try {
- document.execCommand("copy");
- } catch(e) {
-
- }
- select.removeAllRanges();
- });
- }
- });
-
- $("a[href^='#']").on('click', function(e) {
-
- var hash = this.hash;
- if (hash) {
-
- e.preventDefault();
-
-
- var targetName = hash.slice(1);
-
-
- targetName.replace(/'/g, "\\\'").replace(/"/g, "\\\"");
-
-
-
-
-
- var targetSelector = "*[id='" + targetName + "'], *[name='" + targetName + "']";
- var matchingTargets = $(targetSelector);
- if (matchingTargets.length < 1) {
- return;
- }
- if (matchingTargets.length > 1) {
- console.warn("found more than one anchor to go to; will go to the first one");
- }
-
- var matchingTarget = matchingTargets.first();
- var scrollHeight = matchingTarget.offset().top;
-
-
-
- if (!matchingTarget.hasClass("fragment-anchor")) {
- scrollHeight -= 50;
- }
-
- $('html, body').animate(
- {scrollTop: scrollHeight},
- 300,
- function () {
-
- window.location.hash = hash;
- }
- );
- }
- });
-
- $("#jira-search-button").on("click", submitJiraSearchForm);
- $("#jira-search-box").on("keypress", function searchKeypressEventHandler (e) {
- if(e.keyCode == 13) {
- submitJiraSearchForm();
- }
- });
- });
|