Skip to content

Commit 68eb3df

Browse files
author
p01
committed
removed my silly 'url' property, moved the parsing into its own method, and set the _is_parsed flag only when the uri is actually parsed
1 parent 9ec90cb commit 68eb3df

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

src/resource-manager/resource_detail_view.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
5757
};
5858
*/
5959
resource.data = new cls.ResourceManager["1.0"].ResourceData( data );
60+
if(resource.type=='image')
61+
{
62+
var i=new Image();
63+
i.src=resource.data.content.stringData;
64+
resource.data.meta = i.naturalWidth+'x'+i.naturalHeight;
65+
}
6066
if (this.resourceId==id){ this.resource = resource; }
6167
}
6268
this.update();

src/resource-manager/resource_service.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ cls.ResourceContext = function(data)
264264
if (!frame.groups[type]){ type='other'; }
265265

266266
frame.groups[type].push( res.id );
267-
this.resourcesUrlDict[ res.url.url ] = res.id;
267+
this.resourcesUrlDict[ res.url ] = res.id;
268268
/*
269269
if (!res.data)
270270
{
@@ -343,13 +343,18 @@ cls.Resource = function(id)
343343
this._init(id);
344344
}
345345

346-
var ResourcePrototype = function()
346+
cls.ResourcePrototype = function()
347347
{
348+
this._super_init = this._init;
348349
this._init = function(id)
349350
{
351+
this._super_init();
352+
350353
this.id = id;
351354
this.finished = false;
352-
this.url = null;
355+
// debugger;
356+
// this.url = 'http://localhost:8002/dragonfly-stp-1-work/src/client-en.xml';
357+
//this.url = null;
353358
this.location = "No URL";
354359
this.result = null;
355360
this.mime = null;
@@ -358,13 +363,14 @@ var ResourcePrototype = function()
358363
this.type = null;
359364
this.urltype = null;
360365
this.invalid = false;
366+
361367
}
362368

363369
this.update = function(eventname, eventdata)
364370
{
365371
if (eventname == "urlload")
366372
{
367-
this.url = new URI( eventdata.url );
373+
this.url = eventdata.url; // new URI( eventdata.url );
368374
this.urltype = eventdata.urlType;
369375
// fixme: complete list
370376
this.urltypeName = {0: "Unknown", 1: "HTTP", 2: "HTTPS", 3: "File", 4: "Data" }[eventdata.urlType];
@@ -374,7 +380,7 @@ var ResourcePrototype = function()
374380
{
375381
if (!this.url)
376382
{
377-
this.url = new URI( eventdata.url );
383+
this.url = eventdata.url;
378384
}
379385
this.result = eventdata.result;
380386
this.mime = eventdata.mimeType;
@@ -414,10 +420,6 @@ var ResourcePrototype = function()
414420
}
415421
}
416422

417-
this.get_source = function()
418-
{
419-
// cache, file, http, https ..
420-
}
421423

422424
this._guess_type = function()
423425
{
@@ -453,8 +455,14 @@ var ResourcePrototype = function()
453455
}
454456
else
455457
{
456-
this.human_url = this.url.url;
458+
this.human_url = this.url; //.url;
457459
}
458460
}
459461
}
460-
cls.Resource.prototype = new ResourcePrototype();
462+
463+
window.cls.ResourcePrototype.prototype = new URIPrototype("url");
464+
window.cls.Resource.prototype = new window.cls.ResourcePrototype();
465+
/*
466+
ResourcePrototype.prototype = new URIPrototype("url");
467+
cls.Resource.prototype = new ResourcePrototype();
468+
*/

src/resource-manager/resource_templates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ templates.resource_detail =
184184
'class','resource-detail-overview-url'
185185
],
186186
['span',
187-
info.mimeType+' treated as '+info.type,
187+
info.mimeType+' treated as '+info.type +' '+[resource.data.meta],
188188
'class','resource-detail-overview-type'
189189
],
190190
['span',

src/scripts/uri.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ var URIPrototype = function(uri_prop_name)
2121
*/
2222

2323
[
24-
"url",
2524
"hash",
2625
"host",
2726
"pathname",
@@ -32,7 +31,7 @@ var URIPrototype = function(uri_prop_name)
3231
this.__defineGetter__(prop, function()
3332
{
3433
if (!this._is_parsed)
35-
this._init();
34+
this._parse();
3635

3736
return this["_" + prop];
3837
});
@@ -94,15 +93,14 @@ var URIPrototype = function(uri_prop_name)
9493

9594
this.__defineSetter__("origin", function() {});
9695

97-
this._init = function(uri)
96+
this._parse = function(uri)
9897
{
9998
if (!uri && this[uri_prop_name])
10099
uri = this[uri_prop_name];
101100

102101
if (uri)
103102
{
104103
var val = uri;
105-
this._url = uri;
106104

107105
var pos = val.indexOf("#");
108106
if (pos > -1)
@@ -150,11 +148,16 @@ var URIPrototype = function(uri_prop_name)
150148
this._pathname = val;
151149
else
152150
this._pathname = "";
151+
152+
this._is_parsed = true;
153153
}
154154

155-
this._is_parsed = true;
156155
};
157156

157+
this._init = function(uri)
158+
{
159+
this._parse(uri);
160+
}
158161
};
159162

160163
URI.prototype = new URIPrototype();

0 commit comments

Comments
 (0)