home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Offline / Migrate / Port Windows IPC apps to Linux, Part 1 Processes and threads_files / grabtitle.js < prev    next >
Encoding:
JavaScript  |  2005-04-25  |  928 b   |  39 lines

  1. // Used for dW e-mail to a friend function
  2. // Grab only the title from the entire document.title value
  3. function dWSplitChar(ch, str) {
  4.     var start = 0;
  5.     var splits = new Object;
  6.     var end;
  7.     var i = 0;
  8.     while (start < str.length) {
  9.         end = start;
  10.         while (end < str.length &&
  11.                ch.indexOf(str.charAt(end)) < 0) {
  12.             end++;
  13.         }
  14.         splits[i++] = str.substring(start,end);
  15.         start = end + 1;
  16.     }
  17.     splits.length = i;
  18.     return splits;
  19. }
  20.  
  21. function getTitle(){
  22.     var j=0;
  23.     var titlestring="";
  24.     var splitfields = dWSplitChar(':', document.title);
  25.     if (splitfields.length>2) {
  26.         for (j=2;j<splitfields.length;j++) {
  27.             if (j!=2) {
  28.                 titlestring+=": ";
  29.             }
  30.             titlestring+=splitfields[j];
  31.         }
  32.     } else {
  33.         titlestring=document.title;
  34.     }
  35.     return titlestring;
  36. }
  37.  
  38. var justTitle = getTitle();
  39.