Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
diff -rbc Downloads/TV Forecast orig.wdgt/TV/Functions.js Library/Widgets/TV Forecast.wdgt/TV/Functions.js
*** Downloads/TV Forecast orig.wdgt/TV/Functions.js	2009-03-02 08:28:39.000000000 -0500
--- Library/Widgets/TV Forecast.wdgt/TV/Functions.js	2009-03-04 23:35:57.000000000 -0500
***************
*** 1,35 ****
  // Returns the search URL for the specified search text
  function tvShowSearchUrl(text)
  {
!     return "http://www.tv.com/search.php?type=Search&stype=ajax_search&qs=" + 
!         escape(text) + 
!         "&search_type=program&pg_results=0&sort=";
  }

  // Parses TV show search results
! function parseTvShowSearchResults(html)
  {
      var results = new Array();    

!     // global flag allows for multiple matches to occur
!     var result_re = /Show: <a href=\"(.*?)\">(.*?)<\/a>/g;

!     do
!     {
!         var result = result_re.exec(html);
!                 
!         if (result !== null)
!         {
!             var url   = result[1];
!             var title = result[2];

              results.push({
!                 url:   url.replace(/\?.*/, ""),
                  title: title
              });
          }
-     }
-     while (result)

      var too_many_results = false;

--- 1,27 ----
  // Returns the search URL for the specified search text
  function tvShowSearchUrl(text)
  {
!     return "http://www.thetvdb.com/api/GetSeries.php?seriesname=" + 
!         escape(text);
  }

  // Parses TV show search results
! function parseTvShowSearchResults(xml)
  {
      var results = new Array();    

! 	var series = xml.getElementsByTagName("Series");
  	
! 	for (var i=0; i<series.length; i++) {
! 		var serie = series[i];
! 		var title = findChild(serie, "SeriesName").childNodes[0].nodeValue;
! 		var url = "http://dataproxy.pommepause.com/tvforecast/?what=next&source=thetvdb&show_id=" + findChild(serie, "seriesid").childNodes[0].nodeValue;
  		
  		results.push({
!             url:   url,
              title: title
          });
  	}

      var too_many_results = false;

Only in Library/Widgets/TV Forecast.wdgt/TV: TvShowParser2.js
diff -rbc Downloads/TV Forecast orig.wdgt/TvShow.js Library/Widgets/TV Forecast.wdgt/TvShow.js
*** Downloads/TV Forecast orig.wdgt/TvShow.js	2009-03-02 08:28:29.000000000 -0500
--- Library/Widgets/TV Forecast.wdgt/TvShow.js	2009-03-05 23:52:42.000000000 -0500
***************
*** 177,189 ****
  toXml: function()
  {
      return '<subscription>' + 
! 	       '<title>' + escape(this.title) + '</title>' +
! 		   '<url>' + this.url + '</url>' +
  		   '<continent>' + this.continent + '</continent>' +
  		   '<city>' + this.city + '</city>' +
             '</subscription>';
  },

  eventTzClicked: function()
  {
      var tz_id = this.back_id + '-timezone';
--- 177,198 ----
  toXml: function()
  {
      return '<subscription>' + 
! 	       '<title>' + this.xmlize(this.title) + '</title>' +
! 		   '<url>' + this.xmlize(this.url) + '</url>' +
  		   '<continent>' + this.continent + '</continent>' +
  		   '<city>' + this.city + '</city>' +
             '</subscription>';
  },

+ xmlize: function(text)
+ {
+ 	text = text.replace(/&/g, '&amp;');
+ 	text = text.replace(/</g, '&lt;');
+ 	text = text.replace(/>/g, '&gt;');
+ 	text = text.replace(/"/g, '&quot;');
+ 	return text;
+ },
+ 
  eventTzClicked: function()
  {
      var tz_id = this.back_id + '-timezone';
***************
*** 269,275 ****
  	remove_button.setEnabled(true);
  },

! processSummary: function(text)
  {
      this.ajax_request = null;

--- 278,284 ----
  	remove_button.setEnabled(true);
  },

! processSummary: function(text, xml)
  {
      this.ajax_request = null;

***************
*** 286,292 ****
          return;
      }

!     var tv_show_summary = new TvShowParser(text);

      if (tv_show_summary.showAirsNext() == null)
      {
--- 295,301 ----
          return;
      }

!     var tv_show_summary = new TvShowParser2(xml);

      if (tv_show_summary.showAirsNext() == null)
      {
diff -rbc Downloads/TV Forecast orig.wdgt/tv.html Library/Widgets/TV Forecast.wdgt/tv.html
*** Downloads/TV Forecast orig.wdgt/tv.html	2009-01-31 23:31:33.000000000 -0500
--- Library/Widgets/TV Forecast.wdgt/tv.html	2009-03-04 23:30:43.000000000 -0500
***************
*** 16,21 ****
--- 16,22 ----
  	<script type="text/javascript" src="TV/Functions.js" charset="utf-8"></script>
  	<script type="text/javascript" src="TV/ITunes.js" charset="utf-8"></script>
  	<script type="text/javascript" src="TV/TvShowParser.js" charset="utf-8"></script>
+ 	<script type="text/javascript" src="TV/TvShowParser2.js" charset="utf-8"></script>
  	<script type="text/javascript" src="TvShow.js" charset="utf-8"></script>
  	<script type="text/javascript" src="tv.js" charset="utf-8"></script>

diff -rbc Downloads/TV Forecast orig.wdgt/tv.js Library/Widgets/TV Forecast.wdgt/tv.js
*** Downloads/TV Forecast orig.wdgt/tv.js	2009-03-02 08:28:31.000000000 -0500
--- Library/Widgets/TV Forecast.wdgt/tv.js	2009-03-05 23:51:48.000000000 -0500
***************
*** 21,27 ****
  			    this.ajaxCallback(e, callback);
  			}.bind(this),
  			onFailure: function(e) {
! 			    callback("");
  			}
  		});
      },
--- 21,27 ----
  			    this.ajaxCallback(e, callback);
  			}.bind(this),
  			onFailure: function(e) {
! 			    callback("", "");
  			}
  		});
      },
***************
*** 29,45 ****
      ajaxCallback: function(xml_http_request, callback)
      {
  	    var text = xml_http_request.responseText;
  		
  		if (text == null)
  		{
! 			callback('');
  		}
  		else
  		{
  			text = text.replace(/\n/g, "");
  			text = text.replace(/\r/g, "");

! 			callback(text);
  		}
      },

--- 29,46 ----
      ajaxCallback: function(xml_http_request, callback)
      {
  	    var text = xml_http_request.responseText;
+ 	    var xml = xml_http_request.responseXML;
  		
  		if (text == null)
  		{
! 			callback('', '');
  		}
  		else
  		{
   			text = text.replace(/\n/g, "");
   			text = text.replace(/\r/g, "");

! 			callback(text, xml);
  		}
      },

***************
*** 657,665 ****
      search_request = new AjaxRequest(tvShowSearchUrl(text), searchCallback);
  }

! function searchCallback(text)
  {
!     var results = parseTvShowSearchResults(text);    
      var menu    = widget.createMenu();

      if (results == null)
--- 658,666 ----
      search_request = new AjaxRequest(tvShowSearchUrl(text), searchCallback);
  }

! function searchCallback(text, xml)
  {
!     var results = parseTvShowSearchResults(xml);
      var menu    = widget.createMenu();

      if (results == null)