{"id":486,"date":"2014-08-01T14:28:31","date_gmt":"2014-08-01T14:28:31","guid":{"rendered":"http:\/\/blog.law.gmu.edu\/webservices\/?p=486"},"modified":"2014-08-01T14:28:31","modified_gmt":"2014-08-01T14:28:31","slug":"homepage-featured-events-display-using-dom","status":"publish","type":"post","link":"https:\/\/sls.gmu.edu\/web\/2014\/08\/01\/homepage-featured-events-display-using-dom\/","title":{"rendered":"Homepage Featured Events Display Using DOM"},"content":{"rendered":"<p>The featured events on the <a href=\"http:\/\/www.law.gmu.edu\/\">Mason Law homepage<\/a> is pulled from the <a href=\"http:\/\/events.law.gmu.edu\/MasterCalendar\/\">master calendar<\/a>\u2019s RSS. To get the dates and times separated from the titles, accessing the DOM is needed.\u00a0The following codes, which requires jQuery, make the magic happened:<\/p>\n<p><code>$('.rssItemLink').each(<br \/>\nfunction(){<br \/>\n$this = $(this);<br \/>\n$this.<br \/>\nhtml(<span class=\"s1\">'&lt;em&gt;' +<br \/>\n<\/span>$this.<br \/>\nhtml().<br \/>\nreplace(\/((\\d{1,2}\\\/){2}\\d{2,4}\\s*[0-9]{1,2}:[0-9]{1,2}\\s*[apAP][mM]\\s*to\\s*[0-9]{1,2}:[0-9]{1,2}\\s*[apAP][mM])\/,<br \/>\n'<span class=\"s2\">&lt;\/em&gt;<\/span>&lt;b&gt;$1&lt;\/b&gt;'<br \/>\n)<br \/>\n);<br \/>\n}<br \/>\n);<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The featured events on the Mason Law homepage is pulled from the master calendar\u2019s RSS. To get the dates and times separated from the titles, accessing the DOM is needed.\u00a0The following codes, which requires jQuery, make the magic happened: $(&#8216;.rssItemLink&#8217;).each( function(){ $this = $(this); $this. html(&#8216;&lt;em&gt;&#8217; + $this. html(). replace(\/((\\d{1,2}\\\/){2}\\d{2,4}\\s*[0-9]{1,2}:[0-9]{1,2}\\s*[apAP][mM]\\s*to\\s*[0-9]{1,2}:[0-9]{1,2}\\s*[apAP][mM])\/, &#8216;&lt;\/em&gt;&lt;b&gt;$1&lt;\/b&gt;&#8217; ) ); } );<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[11],"tags":[18,28],"class_list":["post-486","post","type-post","status-publish","format-standard","hentry","category-web-development","tag-javascript","tag-rss"],"_links":{"self":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/posts\/486","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/comments?post=486"}],"version-history":[{"count":0,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/posts\/486\/revisions"}],"wp:attachment":[{"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/media?parent=486"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/categories?post=486"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sls.gmu.edu\/web\/wp-json\/wp\/v2\/tags?post=486"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}