473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

JavaScript help for undefined object.

7
I have a blog template that I downloaded for use on my blogger account, and I was having some trouble with an undefined box that's supposed to display the date for each post. I'm more keen on HTML than JS, so I was wondering if anyone could help me with it. I attached a picture of the box in question, and here's the part of the code which I believe is the problem.

function rp(json){document.write('<ul>');for(var i=0;i<numposts;i++){document.write('<li>');var entry=json.feed.entry[i];var posttitle=entry.title.$t;var posturl;if(i==json.feed.entry.length)break;for(var k=0;k<entry.link.length;k++){if(entry.link[k].rel=='alternate'){posturl=entry.link[k].href;break}}posttitle=posttitle.link(posturl);var readmorelink="(more)";readmorelink=readmorelink.li nk(posturl);var postdate=entry.published.$t;var cdyear=postdate.substring(0,4);var cdmonth=postdate.substring(5,7);var cdday=postdate.substring(8,10);var monthnames=new Array();monthnames[1]="Jan";monthnames[2]="Feb";monthnames[3]="Mar";monthnames[4]="Apr";monthnames[5]="May";monthnames[6]="Jun";monthnames[7]="Jul";monthnames[8]="Aug";monthnames[9]="Sep";monthnames[10]="Oct";monthnames[11]="Nov";monthnames[12]="Dec";if("content"in entry){var postcontent=entry.content.$t}else if("summary"in entry){var postcontent=entry.summary.$t}else var postcontent="";var re=/<\S[^>]*>/g;postcontent=postcontent.replace(re,"");document. write(posttitle);if(showpostdate==true)document.wr ite(' - '+monthnames[parseInt(cdmonth,10)]+' '+cdday);if(showpostsummary==true){if(postcontent. length<numchars){document.write(postcontent)}else{ postcontent=postcontent.substring(0,numchars);var quoteEnd=postcontent.lastIndexOf(" ");postcontent=postcontent.substring(0,quoteEnd);d ocument.write(postcontent+'...'+readmorelink)}}doc ument.write('</li>')}document.write('</ul>')}
Attached Images
File Type: jpg Blog.jpg (55.7 KB, 197 views)
Jan 15 '12 #1
7 1947
Dormilich
8,658 Expert Mod 8TB
how do call that function on the page? (this function has only very limited use)
Jan 15 '12 #2
ncost
7
I'm not sure what it's called. The only info about the function that I could find was in the code above. If you like, I could attach the whole template HTML.
Jan 15 '12 #3
Dormilich
8,658 Expert Mod 8TB
I only need the part of the HTML, where this function is in.

PS. calling a function means to execute it. ex. <img src="…" onclick="doSomething()"> or document.getElementById("test").onclick = doSomething;
Jan 15 '12 #4
ncost
7
I looked all through and this is all I could find that might be relevant:

Expand|Select|Wrap|Line Numbers
  1. function removeHtmlTag(strx,chop){ 
  2.     if(strx.indexOf("<")!=-1)
  3.     {
  4.         var s = strx.split("<"); 
  5.         for(var i=0;i<s.length;i++){ 
  6.             if(s[i].indexOf(">")!=-1){ 
  7.                 s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); 
  8.             } 
  9.         } 
  10.         strx =  s.join(""); 
  11.     }
  12.     chop = (chop < strx.length-1) ? chop : strx.length-2; 
  13.     while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++; 
  14.     strx = strx.substring(0,chop-1); 
  15.     return strx+'...'; 
  16. }
  17.  
  18. function createSummaryAndThumb(pID){
  19.     var div = document.getElementById(pID);
  20.     var imgtag = "";
  21.     var img = div.getElementsByTagName("img");
  22.     var summ = summary_noimg;
  23.     if(img.length>=1) {    
  24.         imgtag = '<span style="float:left; padding:0px 10px 5px 0px;"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/></span>';
  25.         summ = summary_img;
  26.     }
  27.  
  28.     var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>';
  29.     div.innerHTML = summary;
  30. }
  31.  
  32. //]]>
  33. </script>
Sorry if that isn't what you're looking for; I don't have too much of an eye for JS coding. If it helps, here's the rest of the template code in an attachment.
Attached Files
File Type: txt Template Code.txt (75.1 KB, 453 views)
Jan 15 '12 #5
Dormilich
8,658 Expert Mod 8TB
hm, I don’t see the rp() function used anywhere. do you have a live page by chance?
Jan 15 '12 #6
ncost
7
Yup! It's kingdomeyes.blogspot.com
Jan 15 '12 #7
ncost
7
Oh, I just fixed it. Turned out it wasn't a JS problem, but a settings issue. Sorry for the trouble and thanks for the help!
Jan 15 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Davide Bruzzone | last post by:
Greetings all... Here's a description of the problem that I'm trying to solve: - I have a Web page from which users can open one or more other windows. - From that web page, the user can then...
15
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the...
4
by: joebob | last post by:
The following script if run in Internet Explorer should display a thumbview of a webpage that you point it to. To test it, replace test.htm with a valid html file. The problem I'm having is that...
2
by: Ophir | last post by:
Hello all I have this problem: I'm displaying a loggin page. If the user entered an invalid UserName/Password I display the page again. When this happens I want to give the user a different...
3
by: Ian Renfrew | last post by:
Does Javascript supply a function that destroys an object? If so, is there a dependancy on Javascript version? Thanks in advance, Ian Renfrew
16
by: Roman Ziak | last post by:
Hello, there were times when I used to be looking for a way to access JavaScript Global object similar to those found in VBScript or PHP ($GLOBALS). At present this has only academic value for...
1
by: Jim Ox | last post by:
I have created a custom validator control that implements the BaseValidator. However I would like to add an attribute to the JavaScript validation object that is rendered at the bottom of the...
1
by: Hoss | last post by:
Hello- I have the following Javascript code function Obj() { obj.squares = new Array(); } Obj.prototype.Load= function(xdoc) { var goat = "head"; xdoc.ProcessNodes("squares/square",...
2
by: kieran5405 | last post by:
i am fairly unfamilar with javascript...i get the following error message on the below code...can anyone tell me how to remove the error. 'iLoopCounter' is undefined Thanks...
7
by: ismailc | last post by:
Good day, I thought i had this sorted but it does not seem to check if the object is undefined / not created. I'm trying to check if object is undefined & i tried a few methos but no luck...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.