//Copyright 2007-2013 Kenneth Yip //Bug //Initialization //Declare global variables //patent or patent application webpage //----------------------------Copyright Kenneth Yip 2013 - ALL RIGHTS RESERVED ---------------------- var a_patent_no = new Array(); var a_patent_app_no = new Array(); var a_patent_title = new Array(); var a_patent_href= new Array(); var global_received_patent_counter=0; var a_patent_abstract = new Array(); var a_patent_ind_claims = new Array(); var a_patent_inventor = new Object(); var a_patent_assignee = new Array(); var a_patent_UPC = new Array(); var a_patent_IPC = new Array(); var a_patent_filed_date= new Object(); var a_granted_date= new Array(); var a_patent_references= new Array(); var a_patent_family= new Array(); var a_patent_keywords= new Array(); var a_ref= new Array(); var a_cited= new Array(); var a_patent_claim=new Array(); var a_patent=new Array(); //a_patent[local_index][key]=value key-assignee, inventor, etc, value-name of assignee var a_field=new Array(); //a_field[key][value].push(local_index) a_field["applicaton_no"]=new Array(); a_field["references"]=new Array(); a_field["assignee"]=new Array(); a_field["inventor"]=new Array(); a_field["filed_date"]=new Array(); a_field["granted_date"]=new Array(); a_field["US_class"]=new Array(); a_field["Int_class"]=new Array(); a_field["keyword"]=new Array(); a_field["reference"]=new Array(); a_field["citedby"]=new Array(); var a_selected_patent=new Array(); var page_num=0; //the search result page var total_hits=0; //total number of hits var num_per_page=2; //number of uspto pages shown in a page a_patent["assignee"]=new Array(); /* Author: Florian Maul */ var containerWidth=$("#right-column-container").width()-20; var DEFAULT_IMAGE_SIZE=240; var DEFAULT_MIN_HEIGHT=120; var a_image=[]; var time_out1,time_out2,time_out3,time_out4,time_out5; var items=[]; var GPlusGallery = (function($) { // reduce width by 1px due to layout problem in IE var containerWidth=0 //Probably due to jquery mobile page swap, the containerWidth is not avaliable. //Therefore need to preset it /* ------------ PRIVATE functions ------------ */ /** Utility function that returns a value or the defaultvalue if the value is null */ var $nz = function(value, defaultvalue) { if( typeof (value) === undefined || value == null) { return defaultvalue; } return value; }; /** * Distribute a delta (integer value) to n items based on * the size (width) of the items thumbnails. * * @method calculateCutOff * @property len the sum of the width of all thumbnails * @property delta the delta (integer number) to be distributed * @property items an array with items of one row */ var calculateCutOff = function(len, delta, items) { // resulting distribution var cutoff = []; var cutsum = 0; // distribute the delta based on the proportion of // thumbnail size to length of all thumbnails. for(var i in items) { var item = items[i]; var fractOfLen = item.twidth / len; cutoff[i] = Math.floor(fractOfLen * delta); cutsum += cutoff[i]; } // still more pixel to distribute because of decimal // fractions that were omitted. var stillToCutOff = delta - cutsum; while(stillToCutOff > 0) { for(i in cutoff) { // distribute pixels evenly until done cutoff[i]++; stillToCutOff--; if (stillToCutOff == 0) break; } } return cutoff; }; var get_div_max_height = function(items) { // resulting distribution var max_height = 0; // distribute the delta based on the proportion of // thumbnail size to length of all thumbnails. for(var i in items) { var item = items[i]; if (item.theight>max_height) max_height=item.theight; } if (max_height 0 && len < maxwidth) { var item = items.shift(); row.push(item); len += (item.twidth + marginsOfImage); console.log ("4 buildImageRow row push :"+items.length+ "len: "+len); } // calculate by how many pixels too long? var delta = len - maxwidth; var div_max_height=get_div_max_height(row); console.log ("max :"+div_max_height); var total_length=0; // if the line is too long, make images smaller if(row.length > 0 && delta > 0) { // calculate the distribution to each image in the row var cutoff = calculateCutOff(len, delta, row); for(var i in row) { console.log("buildImageRow "+i); var pixelsToRemove = cutoff[i]; item = row[i]; // set the max height of the row item.div_max_height=div_max_height; // shrink the width of the image by pixelsToRemove item.vwidth = item.twidth - pixelsToRemove; total_length=total_length+item.vwidth+marginsOfImage; //4 is the padding item.row_pos=i; if (i==0 || i==row.length-1) //the first item and the last item item.padding=0; else item.padding=0; } //add padding to the first picture to make all pictures justified } else { // all images fit in the row, set vx and vwidth for(var i in row) { item = row[i]; item.row_pos=i; // set the max height of the row item.div_max_height=div_max_height; item.vwidth = item.twidth; total_length=total_length+item.vwidth; item.padding=0; total_length=total_length+item.vwidth+marginsOfImage; //4 is the padding } } var padding_length=(maxwidth-total_length)/row.length; for(var i in row) { item = row[i]; item.vx = total_length/row.length; //size of padding-left item.padding=padding_length; console.log ("5 buildImageRow row padding :"+i+ "padding_length: "+padding_length+" maxwidth: "+maxwidth+"total_length: "+total_length); } return row; }; /** * Creates a new thumbail in the image area. An attaches a fade in animation * to the image. */ var createImageElement = function(parent, item,pos) { //console.log("createImageElement "+pos); var imageContainer = $('
'); var overflow = $("
"); overflow.css("width", ""+item.vwidth+"px"); overflow.css("height", ""+item.div_max_height+ "px"); overflow.css("padding-right", ""+item.padding+ "px"); //overflow.css("padding-left", ""+item.vx+ "px"); //console.log("vx: "+item.vx); //console.log(item.vwidth,item.div_max_height,item.theight); overflow.css("overflow", "hidden"); item.thumbUrl=item.thumbUrl.replace("small?","small?bigger=y&"); if (item.thumbUrl.indexOf("small")>0) //US patents var link = $(''); else var link = $(''); /* link.click(function() { alert("clicked"); return false; }); */ var img = $(""); img.attr("src", item.thumbUrl); img.attr("title", item.title); img.attr("name", item.vwidth+" "+item.div_max_height+" "+item.theight+"row pos: "+item.row_pos); if (item.theight>=item.div_max_height) { img.css("height",item.div_max_height); img.css("width", "" + item.vwidth*item.div_max_height/item.theight+ "px"); } else { var new_height=Math.min(item.theight*item.vwidth/item.twidth,item.theight); img.css("height", ""+new_height + "px"); img.css("width", "" + item.vwidth + "px"); img.css("padding-top",""+(item.div_max_height-new_height)/2+"px"); } link.append(img); overflow.append(link); imageContainer.append(overflow); // fade in the image after load //img.bind("load", function () { // $(this).fadeIn(500); //}); parent.find(".clearfix").before(imageContainer); item.el = imageContainer; return imageContainer; }; /** * Updates an exisiting tthumbnail in the image area. */ var updateImageElement = function(item) { /* var overflow = item.el.find("div:first"); var img = overflow.find("img:first"); overflow.css("width", "" + $nz(item.vwidth, 120) + "px"); overflow.css("height", "" + item.div_max_height + "px"); img.css("margin-left", "" + (item.vx ? (-item.vx) : 0) + "px"); //img.css("margin-top", "" + 0 + "px"); */ }; /* ------------ PUBLIC functions ------------ */ return { showImages : function(imageContainer, realItems, temp_width) { containerWidth=temp_width; // Make a copy of the array var items = realItems.slice(); // calculate rows of images which each row fitting into // the specified windowWidth. var rows = []; //alert("1 showImages: "+containerWidth) while(items.length > 0) { rows.push(buildImageRow(containerWidth, items)); console.log("7 showImages rows.push: "+items.length); } //alert("2 showImages: "+items.length+" rows:"+rows.length) var temp_div=$("#console_dump"); for(var r in rows) { //alert("2b showImages r: "+r+" rows[r].length: "+rows[r].length) for(var i in rows[r]) { var item = rows[r][i]; //console.log("showImages: "+r+" "+i); //if(item.el) { // this image is already on the screen, update it // updateImageElement(item); //} else { // create this image //$("#console_dump").text($("#console_dump").text()+" Row "+i+" rows"+r); createImageElement(imageContainer, item,i); //} } } //alert("3 done showImages") } } })(jQuery); (function ($) { // Ajax activity indicator bound to ajax start/stop document events $(document).ajaxStart(function(){ $('#ajaxBusy').show(); }).ajaxStop(function(){ $('#ajaxBusy').hide(); }); $.fn.imageReloader = function (options) { options = $.extend({}, options, { loadingClass: "loading-image", reloadTime: 10000, maxTries: 10 }); var $self = $(this); if ($self.length > 1) { $self.each(function (i, el) { $(el).imageReloader(options); }); return $self; } $self.data("reload-times", 0); var imageHeight = $self.height() var imageWidth = $self.width() var $imageReplacer = $('
'); $imageReplacer.css({height: imageHeight, width: imageWidth}) $imageReplacer.hide(); $imageReplacer.insertAfter($self); var showImage = function () { $self.show(); $imageReplacer.remove(); }; $self.bind("error", function () { console.log("failed ",$self.attr("src")); $self.hide(); }) $self.bind("error", function () { console.log("error image ",$self.attr("src")); $self.hide(); $imageReplacer.show() var reloadTimes = $self.data("reload-times"); if (reloadTimes < options.maxTries) { setTimeout(function () { $self.attr("src", $self.attr("src")); var reloadTimes = $self.data("reload-times"); reloadTimes++; $self.data("reload-times", reloadTimes); }, options.reloadTime); } else if (!$self.is(":visible")) { showImage(); $self.attr("alt", "Image not found :("); } }); $self.bind("load", function () { showImage(); }); return this; }; })(jQuery); //-------------------------------------------------------- // Get Query // //query_counter is the page_num passed in the URL //page_num inside the function is to keep which page the program is running at because there can be >50 patents per page //-------------------------------------------------------- function get_query(query,start_query_counter,query_counter) { //diagrams under a tab if ($(window).width()<800) figure_tab(); console.log("wdith "+$(window).width()); console.log(query,start_query_counter,query_counter); // register AJAX prefilter : options, original options $.ajaxPrefilter(function( options1, originalOptions1, jqXHR1 ) { // retry not set or less than 2 : retry not requested if( !originalOptions1.retryMax || !originalOptions1.retryMax >=2 ) return; // no timeout was setup if( !originalOptions1.timeout >0 ) return; if( originalOptions1.retryCount ) { // increment retry count each time originalOptions1.retryCount++; console.log ("retry 1a: ",originalOptions1.retryCount,jqXHR1); }else{ // init the retry count if not set originalOptions1.retryCount = 1; // copy original error callback on first time originalOptions1._error = originalOptions1.error; // console.log ("retry 1b: ",originalOptions1.url); }; // overwrite error handler for current request options1.error = function( _jqXHR1, _textStatus1, _errorThrown1 ){ console.log("at retry - ",originalOptions1.retryCount); if( originalOptions1.retryCount >= originalOptions1.retryMax || !(_textStatus1=='timeout' || _textStatus1=='error')){ // retry max was exhausted or it is not a timeout error // call original error handler if any if( originalOptions1._error ) originalOptions1._error( _jqXHR1, _textStatus1, _errorThrown1 ); return; }; // Call AJAX again with original options originalOptions1.url=originalOptions1.backup_url $.ajax( originalOptions1); console.log ("retry 1: ",originalOptions1); }; }); //'http://""" + self.request.environ['HTTP_HOST']+"""/uspto?Query='+query+'&page_num='+query_counter m_server=query.length%3+1; //want to get a number between 1 and 3 $.ajax ({ dataType: 'json' ,url: 'http://petapatorpatentinfo'+m_server+'.appspot.com/uspto?'+query+'&page_num='+query_counter ,success: function(data) { var items = []; counter=0; var num_items=a_patent_title.length; //original number of items var row_id=""; $('#myModal2').modal('hide'); $.each(data, function(key, val) { if (key=="page_num") //patent search result page number { page_num=val; } if (key=="a_patent_no") //patent number { for (a_patent_no_key in val) { a_patent_no_val = val[a_patent_no_key]; //console.log("a_patent_no_key: ",a_patent_no_val,start_query_counter,query_counter,a_patent_no_key,((query_counter-start_query_counter)*50+parseInt(a_patent_no_key))); a_patent_no.push (a_patent_no_val); $("#patent_row_"+((query_counter-start_query_counter)*50+parseInt(a_patent_no_key))+"_0").show(); } } if (key=="a_patent_title") //patent title { for (a_patent_title_key in val) { a_patent_title_val=val[a_patent_title_key]; a_patent_title.push (a_patent_title_val); } } if (key=="total_hits") //total hits { $("#totalhits").text("Hits: "+val+", Pg:"+Math.ceil(start_query_counter/2)); total_hits=val; //var page=getURLParameter("page"); if (page_num == "") page=0; if (total_hits>(start_query_counter+num_per_page)*50) { $("#forward-page").show(); } else $("#forward-page").hide(); if (start_query_counter-num_per_page>0) { $("#backward-page").show(); } else $("#backward-page").hide(); } $('#myModal2').modal('hide'); }); var new_num_items=a_patent_title.length-1; //new number of items after the AJAX patent_write_title(num_items,new_num_items,start_query_counter,query_counter) //populate the titles counter_2=0; //keep track how many have returned var t_patent_no=""; var start_index=num_items; //use to keep track the beginning number of index for (var i = num_items; i <= new_num_items; i++) { if (t_patent_no=="") //first item, no - at the front t_patent_no=a_patent_no[i].replace(/,/g,""); else t_patent_no=t_patent_no+"-"+a_patent_no[i].replace(/,/g,""); //if ((i%10==0 || i==new_num_items) && i!=num_items)//send the request for every 10 patents if (i%1==0)//every patent { // register AJAX prefilter : options, original options $.ajaxPrefilter(function( options, originalOptions, jqXHR ) { // retry not set or less than 2 : retry not requested if( !originalOptions.retryMax || !originalOptions.retryMax >=2 ) return; // no timeout was setup if( !originalOptions.timeout >0 ) return; if( originalOptions.retryCount ) { // increment retry count each time originalOptions.retryCount++; //console.log ("retry 2a: ",originalOptions.retryCount); }else{ // init the retry count if not set originalOptions.retryCount = 1; // copy original error callback on first time originalOptions._error = originalOptions.error; console.log ("retry 2b: ",originalOptions.retryCount); }; // overwrite error handler for current request options.error = function( _jqXHR, _textStatus, _errorThrown ){ // retry max was exhausted or it is not a timeout error if( originalOptions.retryCount >= originalOptions.retryMax || !(_textStatus=='timeout' || _textStatus=='error')){ // call original error handler if any if( originalOptions._error ) originalOptions._error( _jqXHR, _textStatus, _errorThrown ); return; }; // Call AJAX again with original options $.ajax( originalOptions); console.log ("at retry 2: ",originalOptions); }; }); //,url: 'http://"""+self.request.environ['HTTP_HOST']+"""/all?patent_no='+ t_patent_no + '&index=' + start_index //console.log('http://"""+self.request.environ['HTTP_HOST']+"""/all?patent_no='+ t_patent_no + '&index=' + start_index); m_server=Math.floor((Math.random()*3)+1); $.ajax ({ dataType: 'json' ,url: 'http://petapatorpatentinfo'+m_server+'.appspot.com/all?patent_no='+ t_patent_no + '&index=0'// + start_index ,success: function(all_patent_data) { for (var j in all_patent_data) { var each_patent=all_patent_data[j]; if (each_patent["patent_no"].length<9) //not patent application { if (each_patent["patent_no"].substr(0,1)=="D") //design patent { var local_index=a_patent_no.indexOf("D"+each_patent["patent_no"].substr(1,3)+","+each_patent["patent_no"].substr(4,3)); } else { var local_index=a_patent_no.indexOf(each_patent["patent_no"].substr(0,1)+","+each_patent["patent_no"].substr(1,3)+","+each_patent["patent_no"].substr(4,3)); } } else var local_index=a_patent_no.indexOf(each_patent["patent_no"]); //A special case when there is only one patent. There is no comma in the patent number if (a_patent_no!="" && local_index==-1) local_index=0; global_received_patent_counter++; //get_espacenet(local_index,each_patent["patent_no"]); <-- var assignee=each_patent["assignee"] || ""; //this is use to associate inventors with assignee for (var k in each_patent) { each_patent_data=each_patent[k]; var items_2 = []; counter_2++; patent_push_array (local_index,k,assignee,each_patent_data,counter_2); } } } ,error: function( jqXHR, textStatus, errorThrown ) { // display error status on failure console.log( 'error: ' + textStatus ); } ,timeout:35000 ,retryMax: 25 ,retryCount:0 }); t_patent_no=""; //reset start_index=i+1; //because the batches are 0-10, 11-20, ... 191-200 } }; } ,error: function( jqXHR1, textStatus1, errorThrown1) { // display error status on failure console.log( 'ERROR: ' + textStatus1 ); } ,timeout:35000 ,retryMax: 25 ,retryCount:0 //,backup_url: 'http://www.d-publish.com/aspator/uspto_search_result.php?'+query+'&page_num='+query_counter }); getcitation(); } //-------------------------------------------------------- // Goto Page //-------------------------------------------------------- function gotopage(direction) { var page_num = getURLParameter("page_num"); var query = getURLParameter("Query"); var auto_search_query = getURLParameter("hidden_auto_search_query"); //use auto_search_query if query is empty if (query==null && auto_search_query!=null) query=auto_search_query; var ga = getURLParameter("ga"); if (direction==-1) page_num=parseInt(page_num)-num_per_page; if (direction==1) page_num=parseInt(page_num)+num_per_page; if (page_num<1) page_num=1; window.location.href="/search.html?page_num="+page_num+"&Query="+encodeURI(query)+"&ga="+ga; } //-------------------------------------------------------- // Get Espacenet //-------------------------------------------------------- function get_espacenet(local_index,patent_no) { var sUrl = 'http://ops.epo.org/3.0/rest-services/family/publication/docdb/US'+patent_no.replace(/,/g,"") + '/biblio/.js?callback=?'; // Call getJSON function with url and anonymous callback //function $.getJSON(sUrl, function(oData) { if (oData['ops:world-patent-data'] != null && oData['ops:world-patent-data'] != '') { $("
    ", { id: 'ol_espacenet_'+local_index }).appendTo("#tab_patent_no_content_R_espacenet_"+local_index); $.each($(oData['ops:world-patent-data']['ops:patent-family']['ops:family-member']), function(){ $.each(this, function(jIndex, nValue) { var s_return=loop_object(nValue,"tab_patent_no_content_R_espacenet_"+local_index,""); if (s_return.indexOf("family-id")>-1 && s_return.indexOf("country")>-1) //patent family { var pos_doc_num=s_return.indexOf("*@doc-number+"); var pos_kind=s_return.indexOf("*@kind+"); var country=s_return.substr(pos_doc_num-2,2); var doc_num=s_return.substring(pos_doc_num+13,pos_kind); var kind_type=s_return.substring(pos_kind+7,s_return.indexOf(":bibliographic-data")); $("
  1. ", { text: country+"-"+doc_num+"-"+kind_type }).appendTo("#ol_espacenet_"+local_index); } }); }); } }); } function loop_object(object,div_id,temp_string) { for (var property in object) { if (object.hasOwnProperty(property)) { if (typeof object[property] == "object"){ temp_string=temp_string+":"+property; loop_object(object[property],div_id,temp_string); }else{ temp_string=temp_string+"*"+property+"+"+object[property]; } } } return temp_string; } function convert_patent_no(i_patent_no) { var o_patent_no=""; o_patent_no=i_patent_no.toString().replace(/,/g,""); if (o_patent_no.substr(0,1)!="D" && o_patent_no.length<10) //patent o_patent_no="0"+o_patent_no; if (o_patent_no.substr(0,1)=="D") //design patent o_patent_no="D0"+o_patent_no.substring(1); return o_patent_no; } function button_collapse(id) { var patent_index=(event.target.id).substring(14); patent_index=patent_index.slice(0,-2); var collapse_id="#collapse_"+patent_index; switch((event.target.id).substr(-1,1)) { case "A": collapse_id=collapse_id+"-1"; break; case "I": collapse_id=collapse_id+"-2"; break; case "C": collapse_id=collapse_id+"-3"; break; case "D": collapse_id=collapse_id+"-4"; break; case "E": collapse_id=collapse_id+"-5"; break; } $(collapse_id).collapse('toggle'); } function patent_write_title (num_items,new_num_items,start_query_counter,query_counter) { for (var i = num_items; i <= new_num_items; i++) { var patent_title=a_patent_title[i]; var patent_no=a_patent_no[i]; var converted_patent_no=convert_patent_no(patent_no).substring(1); var link_patent_no = document.createElement('a'); var linkText = document.createTextNode(patent_no); link_patent_no.appendChild(linkText); link_patent_no.title = patent_no; link_patent_no.target="_blank"; link_patent_no.href = "read2.html?patent_no="+patent_no.replace(/,/g,""); $("#patent_well_"+i).append(' '+(i+1+(start_query_counter-1)*50)+". ",link_patent_no,' '+patent_title+' exp / min  PDF
    '+'
'); $(".select_checkbox").click(function() { var id=(this.id).substring((this.id).indexOf("_")+1); if (this.checked) { document.getElementById("patent_well_"+id).style.backgroundColor='#FAAC58'; } else document.getElementById("patent_well_"+id).style.backgroundColor='#f5f5f5'; }); load_images(i); } } //rotate image function rotate_image (obj_id) { //get the degree var degree=$("#"+obj_id).data("rotate"); degree +=90; $("#"+obj_id).rotate(degree); //update the degree $("#"+obj_id).data("rotate",degree); } //show all the pictures of a patent function load_images(i) { console.log(i,a_patent_no[i]); patent_no=a_patent_no[i].replace(/,/g,""); $("
", { id: "div_image_grid_container"+i, class: "grid-container", }).appendTo("#patent_no_diagram_"+i); $("
", { id: "div_image_"+patent_no, align: "center", class: "grid-div", }).appendTo("#div_image_grid_container"+i); $("
", { id: "div_tab_image_"+patent_no, align: "center", style: "white-space:nowrap;overflow-x:auto;", }).appendTo("#tab_patent_no_content_D_"+i); if (patent_no.length==7 && patent_no.substr(0,1)!="D") //patent patent_no="0"+patent_no; m_server=patent_no.length%3+1; $.get('http://m'+m_server+'.petapator.com/patentimagelist?server=2&patent_no='+patent_no,function(data) { var img_src = data.match(/img src(.*?)tif/g); //console.log(img_src); if (img_src!=null) { var patent_no=img_src[0].substring(img_src[0].indexOf("Docid")+6,img_src[0].indexOf("PageNum")-3); if (patent_no.indexOf("D0")==0) patent_no="D"+patent_no.substring(2); if (patent_no.substring(0,1)=="0") patent_no=patent_no.substring(1); console.log(patent_no); for (var i=0;i", { id: "image_holder_"+i+"_"+temp_title, //class: "sub_image", align: "center", style: "display:inline-block;width:252px;height:360px;margin: 0px auto 0px auto;padding:2px 2px 2px 2px;background-color:#FFFFFF;border:2px solid #a1a1a1;", }).appendTo("#div_image_"+temp_title); //diagrams under a tab if ($(window).width()<800) { $("#image_holder_"+i+"_"+temp_title).appendTo("#div_tab_image_"+patent_no); } else { $("#image_holder_"+i+"_"+temp_title).appendTo("#div_image_"+patent_no); } document.getElementById("image_holder_"+i+"_"+temp_title).innerHTML=""; //lightbox $("", { id: "href_"+i+"_"+temp_title, href: "#", onclick: "show_large('"+(img_src[i].substr(9)).replace("small?","small?bigger=y&")+"','"+temp_title+"','"+i+"');return false;", }).appendTo("#image_holder_"+i+"_"+temp_title); $("", { id: "image_"+i+"_"+temp_title, src: (img_src[i].substr(9)).replace("small?","small?bigger=y&"), style: "display:block;", }).appendTo("#href_"+i+"_"+temp_title); var temp_obj=$("#image_"+i+"_"+temp_title); temp_obj.data("rotate",0); temp_obj.load(function(){ var image_x,image_y,div_x,div_y; var div_parent=$(this).parent().get(0); image_x=$(this)[0].width; image_y=$(this)[0].height; if (image_x*330/245>image_y) { if (image_x>245) { $(this)[0].width=245; $(this)[0].height=image_y*245/image_x; } } else { if (image_y>330) { $(this)[0].height=330; $(this)[0].width=image_x*330/image_y; } } $(this)[0].style.display="block"; }); } } }); } //-------------------------------------------------- // Patent Push Array //-------------------------------------------------- function patent_push_array (local_index,key,assignee_name,element,counter) { if (key == "claims") { a_patent_claim[local_index]=[]; var temp_string=""; var temp_ind_claim=""; for (var i=0;i
"; formatclaims(each_claim_array_val["text"],document.getElementById("tab_patent_no_content_C_"+local_index)); if (each_claim_array_val["type"]=="I") { temp_ind_claim=temp_ind_claim+each_claim_array_val["text"]+"
"; formatclaims(each_claim_array_val["text"],document.getElementById("tab_patent_no_content_I_"+local_index)); } } $("#span_title_"+local_index).append($("

").text("("+wordimportance(temp_string,local_index)+") ")); } else if (key == "references") { a_patent[local_index]["reference"]=[]; var counter=0; $("

    ", { id: 'ol_ref_'+local_index }).appendTo("#tab_patent_no_content_R_ref_"+local_index); for (var i in element) { var each_references_array_val=element[i]["no"]; //for (var j in each_references_array_val) //{ //each_references_val = each_references_array_val[j] //a_patent[local_index]["references"].push(each_references_val); a_patent[local_index]["reference"].push(each_references_array_val); //for javascript associative array, integer cannot be used a key if (!(typeof a_field["reference"][" "+each_references_array_val] != 'undefined' && a_field["reference"][" "+each_references_array_val] instanceof Array)) a_field["reference"][" "+each_references_array_val] = new Array(); a_field["reference"][" "+each_references_array_val].push(local_index); //} $("
  1. ", { id: 'li_ref_'+local_index+"_"+i, }).appendTo("#ol_ref_"+local_index); var temp_patent_no=each_references_array_val.toString(); if (temp_patent_no.length==7) //granted patent temp_patent_no=each_references_array_val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); $("", { id: 'a_ref_'+local_index+"_"+i, html:""+temp_patent_no+" " }).appendTo("#li_ref_"+local_index+"_"+i); } } else if (key == "US_class" || key=="Int_class") { a_patent[local_index][key]=[]; //initalize the array var a_class=(element.replace(/ /g,"")).split(";"); for (var i=0; i").text("Assignees:")); $("#tab_patent_no_content_B_"+local_index).append(document.createTextNode(" "+element)); $("#tab_patent_no_content_B_"+local_index).append(document.createElement ("br")); $("#span_title_"+local_index).append($("

    ").text(element.substring(0,Math.max(element.indexOf("("),element.indexOf(","),12)))); } if (key=="abstract") { $("#tab_patent_no_content_A_"+local_index).text(a_patent[local_index]["abstract"]); var trimmedString = a_patent[local_index]["abstract"].substr(0, 200); //re-trim if we are in the middle of a word trimmedString = trimmedString.substr(0, Math.min(trimmedString.length, trimmedString.lastIndexOf(" ")))+" ..."; $("#span_title_lower_"+local_index).append($("

    ").text(trimmedString)); } if (key=="inventor") { //remove the brackets and the contents inside var a_temp_inventor=element.split("),"); var a_temp_assignee = (assignee_name.substring(0,assignee_name.indexOf("("))) if (a_temp_assignee.length>25) { a_temp_assignee=a_temp_assignee.substr(0, 20); //re-trim if we are in the middle of a word a_temp_assignee = a_temp_assignee.substr(0, Math.min(a_temp_assignee.length, a_temp_assignee.lastIndexOf(" ")))+" ..."; } $("#tab_patent_no_content_B_"+local_index).append($("

  2. ' + key +': '+(a_temp[key]).length+'
  3. '); data.push((a_temp[key]).length); datay.push(key); } barchart(data,datay,"placeholder_assignee","myCarousel_stat_1"); //case "inventor": $('#inventor_ul').empty(); $('#inventor_table').empty(); $('#placeholder_inventor').empty(); var key; var i=0; var data=new Array(); var datay=new Array(); a_temp=associativeSort(a_patent_inventor); $("#analyzer_div").append('
    '); for (key in a_temp) { i++; $("#inventor_ul").append('
  4. ' + key +': '+(a_temp[key]).length+'
  5. '); $("#inventor_table").append('
    ' + key +' ('+(a_temp[key]).length+")
    "); data.push((a_temp[key]).length); datay.push(key); } barchart(data,datay,"placeholder_inventor","myCarousel_stat_2"); //case "filed_date": $('#filed_date_ul').empty(); $('#filed_date_table').empty(); $('#analyzer_div').empty(); var key; var i=0; var data=new Array(); var datay=new Array(); a_temp=associativeSort(a_patent_filed_date); $("#analyzer_div").append('
    '); for (key in a_temp) { i++; //$("#filed_date_ul").append('
  6. ' + key +': '+(a_temp[key]).length+'
  7. '); //$("#filed_date_table").append('
    ' + key +' ('+(a_temp[key]).length+")
    "); data.push((a_temp[key]).length); datay.push(key); } barchart (data,datay,"analyzer_div","analyzer_div2"); */ } function cat_patent(category,choice) { console.log(choice); console.log(category); console.log(Object.size(a_patent_inventor)); console.log(Object.size(a_patent_filed_date)); var a_stat_patent=new Array(); for (i=0;i0) //some patents need to be hid { for (i=0;i<200;i++) { $("#patent_row_"+i).hide(); } $.each(a_stat_patent,function(j, el){ console.log("hide ",j,el); $("#patent_row_"+el).show(); }); } else //show all patents { for (i=0;i<200;i++) { $("#patent_row_"+i).show(); } } /* switch (category) { case "filed_date": for (key in a_patent_filed_date) { //console.log(key); if (a_patent_filed_date[key].id==choice) { console.log(a_patent_filed_date[key]); } } break; case "inventor": for (key in a_patent_inventor) { //console.log(key,a_patent_inventor[key].id); if (a_patent_inventor[key].id==choice) { console.log(a_patent_inventor[key]); } } break; } */ } //------------------------------------------------------------------- // Select the category to display //------------------------------------------------------------------- function group_select(selection) { var s_temp2=""; //console.log($('.patent_tab a[href^="#tab_patent_no_content"]')) $('.patent_tab a[href^="#tab_patent_no_content_'+selection+'_"]').tab('show') /* switch (selection) { case "A": $('.patent_tab li:eq(0) a').tab('show'); break; case "I": $('.patent_tab a[href^="#tab_patent_no_content_I_"]').tab('show'); break; case "C": $('.patent_tab a:last').tab('show'); break; case "B": $('.patent_tab li:eq(3) a').tab('show'); $('.patent_tab_B').show(); break; case "R": $('.patent_tab li:eq(4) a').tab('show'); break; case "F": $('.patent_tab li:eq(5) a').tab('show'); break; } */ /* for (var i=0;i<200;i++) { var temp_id="tab_patent_no_content_"+i+"_"+selection; var tab_id="patent_no_content_"+i; // if (document.getElementById(temp_id)) // { s_temp2 = $('#'+tab_id+' a[href="#' + temp_id + '"]'); s_temp2.tab('show'); // } } */ } Object.size = function(obj) { var size = 0, key; for (key in obj) { if (obj.hasOwnProperty(key)) size++; } return size; }; //sort an associative array based onthe the key name function associativeSort(givenArray, keyToSort) { var results = []; var temp = []; for(var key in givenArray) { temp.push(key); } temp = temp.sort(); for(var x = 0; x < temp.length; x++) { results[temp[x]] = givenArray[temp[x]]; } return results; } function wordimportance(full_sentence,local_index) { var stopwords=[" computer-readable storage "," computer readable storage "," computer-readable media "," computer readable media "," at least "," computer readable "," based on"," according "," claim "," being ", "the "," a "," an "," and "," after ", " apparatus ", " of ", " for ", " to ", " about "," an "," and "," are "," as "," at "," based "," be "," by "," can "," com "," comprises " ," comprising " ," corresponding "," each "," first "," further "," for "," from"," function "," have "," having "," has "," how "," if "," in "," includes "," is "," it "," its "," least "," means "," more than "," method "," most ", " more "," no "," not "," of "," one "," on "," or "," other ","plurality", " process "," second "," should ", " storage medium "," such "," th "," that "," thereby "," this ", " their "," third "," to "," was "," what "," when "," where "," wherein "," whether "," which "," who "," whose "," will ", " with "," within "," said ", " one ", " two ", " than ", " then "," three ", " four ", " five ", " six ", " seven ", " eight ", " nine "]; full_sentence=full_sentence.replace(/(\d|\d\d|\d\d\d)/g," "); full_sentence=full_sentence.replace(/\s{2,}/g, ' '); var a_words_2=full_sentence.match(/((\w|-)+ ){2}/g); //2 or 3 words var a_words_3=full_sentence.match(/((\w|-)+ ){3}/g); //2 or 3 words var a_words=a_words_3.concat(a_words_2) var a_word_sorted=sortByFrequencyAndRemoveDuplicates(a_words); for (var i = 0; i < stopwords.length; i++) { var current_word = stopwords[i]; for (var j = 0; j < a_word_sorted.length; j++) { var temp_word=" "+a_word_sorted[j]["text"]+" "; if (temp_word.toLowerCase().indexOf(current_word)>-1 || temp_word.toLowerCase().indexOf(",")>-1 || temp_word.toLowerCase().indexOf(";")>-1 || temp_word.toLowerCase().indexOf("\\n")>-1 || temp_word.toLowerCase().indexOf("\\r")>-1 || temp_word.toLowerCase().indexOf(":")>-1) { a_word_sorted.splice(j,1); j--; //update index for removed element } } } var s_return=""; a_patent[local_index]["keyword"]=new Array(); for (var i in a_word_sorted) { var temp_word=a_word_sorted[i].text.slice(0,-1); if (i==0) s_return=(temp_word); else if (i<5) s_return=s_return+", "+temp_word; if (!(typeof a_field["keyword"][temp_word] != 'undefined' && a_field["keyword"][temp_word] instanceof Array)) a_field["keyword"][temp_word]=new Array(); if (i<5) //only use the first 10 popular words { a_field["keyword"][temp_word].push(local_index); a_patent[local_index]["keyword"].push(temp_word); } } return s_return; } function sortByFrequencyAndRemoveDuplicates(array) { var frequency = {}, value; // compute frequencies of each value for(var i = 0; i < array.length; i++) { value = array[i]; if(value in frequency) { frequency[value]++; } else { frequency[value] = 1; } } // make array from the frequency object to de-duplicate var uniques = []; var counter=0; for(value in frequency) { if (frequency[value]>1) //not include those only appears once { uniques[counter] = {}; uniques[counter]["text"]=value; uniques[counter]["weight"]=frequency[value]; counter ++; } } // sort the uniques array in descending order by frequency function compareFrequency(a, b) { //return frequency[b] - frequency[a]; return b.weight - a.weight; } return uniques.sort(compareFrequency); } function formatclaims(s_claim,p) { var splitresult = s_claim.split(":"); //pretty formatting only when there is a : and ; if (splitresult.length>1 && (s_claim.split(";")).length>1) { for(var l = 0; l < splitresult.length; l++) { var s_claim_2=splitresult[l]; var splitresult_2 = s_claim_2.split(";"); //need to have at least one ; in nested : if (splitresult_2.length>1) { var ulTag = document.createElement("ul"); for(var m = 0; m < splitresult_2.length; m++) { if (m==0 && p!=null) { p.appendChild(ulTag); } var newLI = document.createElement("li"); //do not print ; if the last one. /* if (m==splitresult_2.length-1) //check if the colon is at the ; lines, if so add back the colon if (limg_height) { y_margin=(img_width-img_height)/2; img_height=img_width; } else { x_margin=(img_height-img_width)/2; img_width=img_height; } $("#large_image").attr("src",src); $("#large_image").data("rotate",0); //$("#modal_large_image").attr("style","height:"+(img_height+100)+"px;width:"+(img_width+100)+"px"); //$("#large_image").attr("style","margin:"+y_margin+"px "+x_margin+"px "+y_margin+"px "+x_margin+"px;"); $("#modal_large_image").modal('show'); } function getURLParameter(paramName) { var searchString = window.location.search.substring(1), i, val, params = searchString.split("&"); for (i=0;i=2 ) return; // no timeout was setup if( !originalOptions.timeout >0 ) return; if( originalOptions.retryCount ) { // increment retry count each time originalOptions.retryCount++; //console.log ("retry 2a: ",originalOptions.retryCount); }else{ // init the retry count if not set originalOptions.retryCount = 1; // copy original error callback on first time originalOptions._error = originalOptions.error; console.log ("retry 2b: ",originalOptions.retryCount); }; // overwrite error handler for current request options.error = function( _jqXHR, _textStatus, _errorThrown ){ // retry max was exhausted or it is not a timeout error if( originalOptions.retryCount >= originalOptions.retryMax || !(_textStatus=='timeout' || _textStatus=='error')){ // call original error handler if any if( originalOptions._error ) originalOptions._error( _jqXHR, _textStatus, _errorThrown ); return; }; // Call AJAX again with original options $.ajax( originalOptions); console.log ("retry 2: ",originalOptions); }; }); //,url: 'http://"""+self.request.environ['HTTP_HOST']+"""/all?patent_no='+ t_patent_no + '&index=' + start_index //console.log('http://"""+self.request.environ['HTTP_HOST']+"""/all?patent_no='+ t_patent_no + '&index=' + start_index); m_server=Math.floor((Math.random()*3)+1); $.ajax ({ dataType: 'json' ,url: 'http://petapatorpatentinfo'+m_server+'.appspot.com/all?c=y&patent_no='+ t_patent_no + '&index=' + start_index ,success: function(all_patent_data) { for (var j in all_patent_data) { var each_patent=all_patent_data[j]; var local_index=each_patent["index"]; var hits=each_patent["hits"]; var patent_no=each_patent["patent_no"]; var citedby=each_patent["citedby"]; a_cited[local_index]=new Array(); //each a_cited element holds an array of citations a_patent["citedby"]=citedby; $("
      ", { id: 'ol_citation_'+local_index }).appendTo("#tab_patent_no_content_R_citation_"+local_index); for (var k in citedby) { var each_citation= new Object(); each_citation.title=citedby[k]["title"]; each_citation.id=citedby[k]["id"]; each_citation.patent_no=citedby[k]["patent_no"]; a_cited[local_index][k]=each_citation; $("
    1. ", { html:""+each_citation.patent_no+" "+each_citation.title }).appendTo("#ol_citation_"+local_index); } if (a_cited[local_index].length==0) $("#tab_patent_no_content_R_citation_"+local_index).append("No citation found"); } } ,error: function( jqXHR, textStatus, errorThrown ) { // display error status on failure console.log( 'error: ' + textStatus ); } ,timeout:35000 ,retryMax: 25 }); t_patent_no=""; //reset start_index=i+1; //because the batches are 0-10, 11-20, ... 191-200 } } } function exportCSV() { $('#modal_export_CSV').modal('show'); var ctab="%09"; var next_line="%0A"; var a_array_name=["index","patent_no","title","abstract","references","granted_date","inventor","assignee","application_no","filed_date","PCT_filed_date","US_class","Int_class","field_search","family","keywords","citedby"]; var a_array2=[a_patent_no,a_patent_app_no,a_patent_title,a_patent_assignee,a_patent_inventor,a_patent_abstract,a_patent_claim,a_patent_references,a_cited,a_patent_family,a_patent_filed_date,a_granted_date,a_patent_UPC,a_patent_IPC,a_patent_keywords]; var start_string="Index"+ctab+"Patent_Number"+ctab+"Title"+ctab+"Abstract"+ctab+"References"+ctab+"Grant Date"+ctab+"Inventor"+ctab+"Assignee"+ctab+"Application Number"+ctab+"Filing Date"+ctab+"PCT Filing Date"+ctab+"US_Class"+ctab+"IPC"+ctab+"Field of Search"+ctab+"Family"+ctab+"Keywords"+ctab+"Cited By"+ctab+"Claims"+next_line; var all_string=""; for (var i=0;i-1) i_new_line=s_temp.indexOf("("); else i_new_line=s_temp.indexOf(" "); return s_temp.substring(0, Math.min(i_new_line,d.r/2)); }); node.append("text") .attr("dy", ".70em") .attr("font-size", "x-small") .style("text-anchor", "middle") .text(function(d) { var s_temp=d.className; var i_new_line=0; if (s_temp.substring(0,1)==" ") s_temp=s_temp.substring(0); if (s_temp.indexOf("(")>-1) i_new_line=s_temp.indexOf("("); else i_new_line=s_temp.indexOf(" "); return s_temp.substring(i_new_line,i_new_line+d.r/2); }); // Returns a flattened hierarchy containing all leaf nodes under the root. function classes(root) { var classes = []; function recurse(name, node) { if (node.children) node.children.forEach(function(child) { recurse(node.name, child); }); else classes.push({packageName: name, className: node.name, value: node.size, patentName:node.patent}); } recurse(null, root); return {children: classes}; } d3.select(self.frameElement).style("height", h + "px"); function mouseover(p) { d3.selectAll("#"+placeholder).classed("node", function(d, i) { return i == p.y; }); } function mouseout() { d3.selectAll("#"+placeholder).classed("node", false); } } //--------------------------------------------------------------------- // Matrix //--------------------------------------------------------------------- function matrix(data,datay,placeholder,placeholder_div) { var margin = {top: 100, right: 10, bottom: 20, left: 200}, width = $(window).width() - margin.left - margin.right, height = $(window).height() - margin.top - margin.bottom; var x = d3.scale.ordinal().rangeBands([0, width]), z = d3.scale.linear().domain([0, 4]).clamp(true), c = d3.scale.category10().domain(d3.range(10)); $("#"+placeholder).width(width+20); $("#"+placeholder).height(height+20); $("#"+placeholder_div).height(height+50); var svg = d3.select("#"+placeholder).append("svg") .attr("width", width) .attr("height", height) .style("margin-left", margin.left + "px") .append("g") .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); var matrix = [], nodes = data, n = nodes.length; // Compute index per node. nodes.forEach(function(node, i) { node.index = i; node.count = 0; matrix[i] = d3.range(n).map(function(j) { return {x: j, y: i, z: 0}; }); }); // Convert links to matrix; count character occurrences. datay.forEach(function(datay) { matrix[datay.source][datay.target].z += datay.value; matrix[datay.target][datay.source].z += datay.value; matrix[datay.source][datay.source].z += datay.value; matrix[datay.target][datay.target].z += datay.value; nodes[datay.source].count += datay.value; nodes[datay.target].count += datay.value; }); // Precompute the orders. var orders = { name: d3.range(n).sort(function(a, b) { return d3.ascending(nodes[a].name, nodes[b].name); }), count: d3.range(n).sort(function(a, b) { return nodes[b].count - nodes[a].count; }), group: d3.range(n).sort(function(a, b) { return nodes[b].group - nodes[a].group; }) }; // The default sort order. x.domain(orders.name); svg.append("rect") .attr("fill", "#fff") .attr("width", width) .attr("height", height); var row = svg.selectAll(".row") .data(matrix) .enter().append("g") .attr("class", "row") .attr("transform", function(d, i) { return "translate(0," + x(i) + ")"; }) .each(row); row.append("line") .attr("x2", width); row.append("text") .attr("x", -6) .attr("y", x.rangeBand() / 2) .attr("dy", ".32em") .attr("text-anchor", "end") .attr("font-size", "x-small") .text(function(d, i) { return nodes[i].name; }); var column = svg.selectAll(".column") .data(matrix) .enter().append("g") .attr("class", "column") .attr("transform", function(d, i) { return "translate(" + x(i) + ")rotate(-90)"; }); column.append("line") .attr("x1", -width); column.append("text") .attr("x", 6) .attr("y", x.rangeBand() / 2) .attr("dy", ".32em") .attr("text-anchor", "start") .attr("font-size", "x-small") .text(function(d, i) { return nodes[i].name; }); function row(row) { var cell = d3.select(this).selectAll(".cell") .data(row.filter(function(d) { return d.z; })) .enter().append("rect") .attr("class", "cell") .attr("x", function(d) { return x(d.x); }) .attr("width", x.rangeBand()) .attr("height", x.rangeBand()) .style("fill-opacity", function(d) { //return z(d.z); return d.z/20; }) .style("fill", function(d) { return nodes[d.x].group == nodes[d.y].group ? c(nodes[d.x].group) : null; }) .on("mouseover", mouseover) .on("mouseout", mouseout); } function mouseover(p) { d3.selectAll(".row text").classed("active", function(d, i) { return i == p.y; }); d3.selectAll(".column text").classed("active", function(d, i) { return i == p.x; }); } function mouseout() { d3.selectAll("text").classed("active", false); } d3.select("#order").on("change", function() { clearTimeout(timeout); order(this.value); }); function order(value) { x.domain(orders[value]); var t = svg.transition().duration(2500); t.selectAll(".row") .delay(function(d, i) { return x(i) * 4; }) .attr("transform", function(d, i) { return "translate(0," + x(i) + ")"; }) .selectAll(".cell") .delay(function(d) { return x(d.x) * 4; }) .attr("x", function(d) { return x(d.x); }); t.selectAll(".column") .delay(function(d, i) { return x(i) * 4; }) .attr("transform", function(d, i) { return "translate(" + x(i) + ")rotate(-90)"; }); } var timeout = setTimeout(function() { order("group"); d3.select("#order").property("selectedIndex", 2).node().focus(); }, 5000); } function chord(data,datay,placeholder,placeholder_div) { var w = $(window).width()-30, h = $(window).height()-20, rx = w / 2, ry = h / 2, m0, rotate = 0; if (h>800) h=800; var splines = []; var cluster = d3.layout.cluster() .size([360, ry - 120]) .sort(function(a, b) { return d3.ascending(a.key, b.key); }); var bundle = d3.layout.bundle(); var line = d3.svg.line.radial() .interpolate("bundle") .tension(.95) .radius(function(d) { return d.y; }) .angle(function(d) { return d.x / 180 * Math.PI; }); $("#"+placeholder).width(w+20); $("#"+placeholder).height(h+20); $("#"+placeholder_div).height(h+50); // Chrome 15 bug: var div = d3.select("#"+placeholder).insert("div", "h2") .style("top", "20px") .style("left", "20px") .style("width", w + "px") .style("height", w + "px") .style("z-index","1") .style("position", "absolute") .style("-webkit-backface-visibility", "hidden"); ; var svg = div.append("svg:svg") .attr("width", w) .attr("height", w) .append("svg:g") .attr("transform", "translate(" + rx + "," + ry + ")"); svg.append("svg:path") .attr("class", "arc") .attr("d", d3.svg.arc().outerRadius(ry - 120).innerRadius(0).startAngle(0).endAngle(2 * Math.PI)) .on("mousedown", mousedown); console.log(packages.root(jQuery.parseJSON(data))); var nodes = cluster.nodes(packages.root(jQuery.parseJSON(data))), links = packages.imports(nodes), splines = bundle(links); var path = svg.selectAll("path.link") .data(links) .enter().append("svg:path") .attr("class", function(d) { return "link source-" + d.source.key + " target-" + d.target.key; }) .attr("d", function(d, i) { return line(splines[i]); }); svg.selectAll("g.node") .data(nodes.filter(function(n) { return !n.children; })) .enter().append("svg:g") .attr("class", "node") .attr("id", function(d) { return "node-" + d.key; }) .attr("transform", function(d) { return "rotate(" + (d.x - 90) + ")translate(" + d.y + ")"; }) .append("svg:text") .attr("dx", function(d) { return d.x < 180 ? 8 : -8; }) .attr("dy", ".23em") .attr("text-anchor", function(d) { return d.x < 180 ? "start" : "end"; }) .attr("transform", function(d) { return d.x < 180 ? null : "rotate(180)"; }) .text(function(d) { return d.name; }) //d.key .on("mouseover", mouseover) .on("mouseout", mouseout); d3.select("input[type=range]").on("change", function() { line.tension(this.value / 100); path.attr("d", function(d, i) { return line(splines[i]); }); }); //d3.select("#analyzer_div") d3.select(window) .on("mousemove", mousemove) .on("mouseup", mouseup); function mouse(e) { return [e.pageX - rx, e.pageY - ry]; } function mousedown() { m0 = mouse(d3.event); d3.event.preventDefault(); } function mousemove() { m0=mouse(d3.event); if (m0) { var m1 = mouse(d3.event), dm = Math.atan2(cross(m0, m1), dot(m0, m1)) * 180 / Math.PI; div.style("-webkit-transform", "translate3d(0," + (ry - rx) + "px,0)rotate3d(0,0,0," + dm + "deg)translate3d(0," + (rx - ry) + "px,0)"); } } function mouseup() { if (m0) { var m1 = mouse(d3.event), dm = Math.atan2(cross(m0, m1), dot(m0, m1)) * 180 / Math.PI; rotate += dm; if (rotate > 360) rotate -= 360; else if (rotate < 0) rotate += 360; m0 = null; div.style("-webkit-transform", "rotate3d(0,0,0,0deg)"); svg .attr("transform", "translate(" + rx + "," + ry + ")rotate(" + rotate + ")") .selectAll("g.node text") .attr("dx", function(d) { return (d.x + rotate) % 360 < 180 ? 8 : -8; }) .attr("text-anchor", function(d) { return (d.x + rotate) % 360 < 180 ? "start" : "end"; }) .attr("transform", function(d) { return (d.x + rotate) % 360 < 180 ? null : "rotate(180)"; }); } } function mouseover(d) { svg.selectAll("path.link.target-" + d.key) .classed("target", true) .each(updateNodes("source", true)); svg.selectAll("path.link.source-" + d.key) .classed("source", true) .each(updateNodes("target", true)); } function mouseout(d) { svg.selectAll("path.link.source-" + d.key) .classed("source", false) .each(updateNodes("target", false)); svg.selectAll("path.link.target-" + d.key) .classed("target", false) .each(updateNodes("source", false)); } function updateNodes(name, value) { return function(d) { if (value) this.parentNode.appendChild(this); svg.select("#node-" + d[name].key).classed(name, value); }; } function cross(a, b) { return a[0] * b[1] - a[1] * b[0]; } function dot(a, b) { return a[0] * b[0] + a[1] * b[1]; } } //----------------------Processing Search by Patent Number-------------- function check_patent_numbers_search() { var flag=true; var x=document.getElementById("search_patent_numbers").value; if (x==null || x=="") { alert("There is no patent number entered"); return false; } else { x=x.replace(/ /g,""); var lines=x.replace(/\\r\\n/g,"\\n").split("\\n"); var new_line=""; for (line_num in lines) { line=lines[line_num]; match = /^(us)?(US)?\d(,)?\d\d\d(,)?\d\d\d$/.exec(line); if (match !=null) { new_line=new_line+" or pn%2F"+line.replace(/(us|US|,)/g,""); //alert(new_line); } else if (line!="") { alert (line+" does not conform the format. Please correct."); flag=false; } } } if (flag) { new_line=new_line.substring(4); $("#search_div").hide(); run_get_query(new_line,1); } else return false; } //----------------------Processing Advanced Search-------------- function quick_adv_search(formname) { var query=""; if (formname=="quick_search") { query=query+"&Query="+encodeURI(document.getElementById("auto_search_query").value); } if (formname=="advanced_search") { query=query+"Query="+encodeURI(document.getElementById("Query").value); } $("#search_div").hide(); //$.mobile.showPageLoadingMsg(); //show the spinning icon run_get_query(query,1); } //-------------------------------------------------------- // Run Get Query //Per page is to determine how many results will appear pare page //num_per_page - 50,100,150 or 200 patents per page //query_counter - to track which page it is processing //-------------------------------------------------------- function run_get_query(query,start_query_counter) { for (var i=0;i1) { var search_word_id=((keyword).id).substr(-1,1); $("#search_word_"+search_word_id+"_result").attr("placeholder",0); var sfontcolor=""; var sbackgroundcolor=""; switch (search_word_id) { case "0": sfontcolor="#FFFFFF"; sbackgroundcolor="#0000CC"; break case "1": sfontcolor="#FFFFFF"; sbackgroundcolor="#00FFCC"; break case "2": sfontcolor="#FFFFFF"; sbackgroundcolor="#6600CC"; break case "3": sfontcolor="#FFFFFF"; sbackgroundcolor="#006600"; break case "4": sfontcolor="#FFFFFF"; sbackgroundcolor="#660000"; break case "5": sfontcolor="#FFFFFF"; sbackgroundcolor="#9900CC"; break case "6": sfontcolor="#FFFFFF"; sbackgroundcolor="#CC0000"; break case "7": sfontcolor="#000000"; sbackgroundcolor="#CCFF00"; break case "8": sfontcolor="#000000"; sbackgroundcolor="#FFFF00"; break case "9": sfontcolor="#FF0000"; sbackgroundcolor="#FFFFCC"; break } var divs = $("body").find("div,p,span");; var patt = new RegExp(search_word_text, 'g'); var excludes = ',html,head,style,title,link,meta,script,object,iframe,img,noscript,cite'; var hit_counter=0; for (var i = 0; i < divs.length; i += 1) { $(divs[i]).contents().each(function() { if(this.nodeType == 3) { this_text=this.textContent; if (patt.test(this_text)==true && (excludes + ',').indexOf(','+this.nodeName.toLowerCase() + ',') === -1 && (excludes + ',').indexOf(','+this.parentNode.nodeName.toLowerCase() + ',') === -1 && this_text!="") { if (this.parentNode.id.indexOf("PETAPATOR_")==-1) { hit_counter=SearchAndReplaceElement(this,this.parentNode,search_word_text,sfontcolor,sbackgroundcolor,search_word_id,hit_counter); } else return false; } } }); //divs[i].innerHTML=divs[i].innerHTML.replace(re,''+search_word_text+''); } //$("#search_word_"+search_word_id+"_result").attr("placeholder",hit_counter); document.getElementById("search_word_"+search_word_id+"_result").textContent=hit_counter; console.log(search_word_text); } } //--------------------------------------------------------------------- // Start Function //--------------------------------------------------------------------- function emailselection() { var patent_list=""; $(".select_checkbox").each(function() { var id=(this.id).substring((this.id).indexOf("_")+1); if (this.checked) { patent_list+="-"+(this.value).replace(/,/g,"");; } }); if (patent_list=="") { alert ("Please select at least one patent."); } else { $("#email_sent_message").show(); patent_list=patent_list.substr(1); patent_url="http://m.petapator.com/all?&tab_url=&patent_no="+patent_list+"&email="+$("#email_address").val(); console.log(patent_url); $.get(patent_url,function(result){ $("#email_sent_message").hide(); alert(result); //document.getElementById("email_waitmessage").innerHTML=""; $("#modal_email_selection").modal("hide") }); } } function load_image(i, obj, items,imageContainer_width) { //no action if the image is not available yet if (obj.width>0) { var item_obj=new Object(); console.log(obj.src); item_obj.twidth=obj.width; item_obj.theight=obj.height; item_obj.title=obj.title; /* if (obj.width<15) { item_obj.twidth=40; item_obj.theight=(obj.height*40)/obj.width; obj.width=40; obj.height=item_obj.theight; console.log("<10? "+item_obj.twidth+" "+item_obj.theight); } */ if (obj.height>=DEFAULT_IMAGE_SIZE) { item_obj.twidth=obj.width*DEFAULT_IMAGE_SIZE/obj.height; item_obj.theight=DEFAULT_IMAGE_SIZE; } else { //obj.src=(obj.src).replace("_m","_n"); item_obj.theight=Math.min(obj.height*4/3,DEFAULT_IMAGE_SIZE); if (item_obj.theight>=DEFAULT_IMAGE_SIZE) { item_obj.twidth=obj.width*(4/3)*DEFAULT_IMAGE_SIZE/(obj.height*4/3); //new width x scale factor } else item_obj.twidth=obj.width*4/3; //item_obj.theight=120; } if (item_obj.twidth+10>imageContainer_width/2) //too long { var new_item_obj_twidth=imageContainer_width/2; item_obj.theight=item_obj.theight*new_item_obj_twidth/item_obj.twidth; item_obj.twidth=new_item_obj_twidth; } //console.log(item_obj.twidth,item_obj.theight,new_item_obj_twidth); item_obj.theight=Math.floor(item_obj.theight); console.log ("item_obj.theight:" +item_obj.theight); item_obj.twidth=Math.floor(item_obj.twidth); item_obj.thumbUrl=obj.src; items.push(item_obj); } } function clear_imagearea() { //$("#results").empty(); $("#right-column-container").empty(); $("
      ", { id: "clearfix", class: "clearfix" }).appendTo("#right-column-container"); } //execute this function when the screen is small to move the figures function figure_tab() { for (i=0;i<100;i++) { //$("#patent_no_content_"+i).attr('class', 'span12'); $("#patent_no_diagram_"+i).css('display', 'none'); $("#tab_patent_diagram_"+i).css('display', 'block'); $("#tab_patent_no_content_C_"+i).css('height', '360px'); } } //--------------------------------------------------------------------- // Start Function //--------------------------------------------------------------------- $(function(){ $('#testbutton').on('click', function (e) { $("#patent_no_4").attr('class', 'span6'); $("#patent_no_5").attr('class', 'span6'); $("#patent_no_6").attr('class', 'span6'); $("#patent_no_7").attr('class', 'span6'); }); $('#testbutton2').on('click', function (e) { $("#patent_no_4").attr('class', 'span6'); $("#patent_no_5").attr('class', 'span6'); $("#patent_no_6").attr('class', 'span6'); $("#patent_no_7").attr('class', 'span6'); }); $(".slow-images").imageReloader(); //var s_query=$("#query_text").val(); var Query=getURLParameter("Query"); var page_num=parseInt(getURLParameter("page_num")); var Auto_Query=getURLParameter("hidden_auto_search_query"); var ga=getURLParameter("ga"); //granted patent or application if (!isNaN(page_num) && ((Query!="" && Query!=null) || (page_num!="" && page_num!=null) || (Auto_Query!="" && Auto_Query!=null))) { var query=""; $('#myModal2').modal('show'); //$("#search_div").hide(); //setTimeout(function(){$('#myModal2').modal('hide');}, 7000); if (Query!=null) s_query="ga="+ga+"&Query="+Query; else if (Auto_Query!=null) s_query="ga="+ga+"&Query="+Auto_Query; else s_query="ga=a"; console.log(s_query,page_num); run_get_query(s_query,page_num,page_num); $("#query_text").attr("placeholder", s_query); $("#query_text").val(s_query); } $('#toppest_page').resize (function(){ }); //load recent posts to the front page //$('#div_forum').load('http://www.petapator.com/f/recent-widget.php', function() { //}); /*---------------------------------------- //Marker at the right, will implement in the next version $('#toppest_page').bind("resize.toppest_page", function(e){ $("#toppest_page_marker") .height($(document).height()) .css({ 'opacity' : 0.4, 'position': 'absolute', 'top': 0, 'right': 0, 'background-color': 'black', 'width': '30px', 'z-index': 300 }); }); */ $('.search_word').bind("change",function() { $('.p_search').each(function(i, obj) { RemoveTags(obj); }); $('.search_word').each(function() { highlighter(this); }); }); $('.highlighter_next').bind("click",function() { console.log (this.id); this.counter=1; }); /* $('.search_word').keypress(function(e) { $('.p_search').each(function(i, obj) { RemoveTags(obj); }); if(e.keyCode==13) $('.search_word').each(function() { highlighter(this); }); }); */ $('#email-form').validate( { rules: { email_address: { required: true, email: true } }, highlight: function(element) { $(element).closest('.control-group').removeClass('success').addClass('error'); }, success: function(element) { element .text('OK!').addClass('valid') .closest('.control-group').removeClass('error').addClass('success'); }, submitHandler:function (form){ emailselection(); } }); packages = { // Lazily construct the package hierarchy from class names. root: function(classes) { var map = {}; function find(name, data) { var node = map[name], i; if (!node) { node = map[name] = data || {name: name, children: []}; if (name.length) { node.parent = find(name.substring(0, i = name.lastIndexOf("."))); node.parent.children.push(node); node.key = name.substring(i + 1); } } return node; } classes.forEach(function(d) { find(d.name, d); }); return map[""]; }, // Return a list of imports for the given array of nodes. imports: function(nodes) { var map = {}, imports = []; // Compute a map from name to node. nodes.forEach(function(d) { map[d.name] = d; }); // For each import, construct a link from the source to target node. nodes.forEach(function(d) { if (d.imports) d.imports.forEach(function(i) { imports.push({source: map[d.name], target: map[i]}); }); }); return imports; } }; })