Changeset 161 for trunk/misc

Show
Ignore:
Timestamp:
05/03/10 11:30:32 (5 months ago)
Author:
mbooth
Message:

Show error text in a fancy tooltip if javascript is enabled in the browser. (The built in Firefox tooltips don't stay visible for long enough to read them.)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/misc/dns-o-matic.py

    r160 r161  
    156156            problem = { 
    157157                       'icon':'error', 
    158                        'text':'Dangling pointer (PTR) record detected for %s!\n\n' % data['lookup_of'] + \ 
     158                       'text':'Dangling pointer (PTR) record detected for %s! \n\n' % data['lookup_of'] + \ 
    159159                              'Perhaps it was left behind when the address (A) record for %s was deleted.' % data['resolves_to'], 
    160160                       } 
     
    205205    # display any problems associated with the record 
    206206    for prob in data['problems']: 
    207         print "      <img src='icons/%s.png' />" % prob['icon'] 
     207        print "      <a rel='tooltip' title='%s'>" % prob['text'] 
     208        print "        <img src='icons/%s.png' alt='%s' />" % (prob['icon'], prob['icon']) 
     209        print "      </a>" 
    208210    print "    </p>" 
    209211 
     
    275277        $(subnet+"_off").css('display', 'none'); 
    276278      }); 
     279 
     280      /* mouseover tooltip event callbacks */ 
     281      $('a[rel=tooltip]').mouseover(function(e) { 
     282        /* steal the title text to use in the tooltip */ 
     283        var msg = $(this).attr('title').replace('\n','<br />'); 
     284        $(this).attr('title',''); 
     285        /* construct the tooltip */ 
     286        $(this).append('<div id="tooltip"><div class="tooltipBody">' + msg + '</div></div>'); 
     287        /* position and show the tooltip */ 
     288        $("#tooltip").css('top', e.pageY + 10 ); 
     289        $("#tooltip").css('left', e.pageX + 20 ); 
     290      }).mousemove(function(e) { 
     291        /* make the tooltip follow the cursor */ 
     292        $("#tooltip").css('top', e.pageY + 10 ); 
     293        $("#tooltip").css('left', e.pageX + 20 ); 
     294      }).mouseout(function() { 
     295        /* put the title text back and destroy the tooltip */ 
     296        $(this).attr('title',$(".tooltipBody").html()); 
     297        $(this).children("div#tooltip").remove(); 
     298      }); 
    277299    }); 
    278300  </script> 
     
    285307      font-family:sans-serif; 
    286308      font-weight:normal; 
    287       font-size:0.75em; 
     309      font-size:0.8em; 
    288310      color:#666; 
    289311      padding:5px; 
     
    292314      margin:0; 
    293315      padding:0; 
     316    } 
     317    img { 
     318      height:0.8em; 
     319      border:0; 
     320    } 
     321    #tooltip { 
     322        position:absolute; 
     323        z-index:9999; 
     324        color:#fff; 
     325        font-size:10px; 
     326        width:275px; 
     327    } 
     328    #tooltip .tooltipBody { 
     329      background-color:#000; 
     330      padding:5px 
    294331    } 
    295332    .record {