forked from Botanical/BotanJS
Reduced some image 301 round trips
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
/** @type {_AstConf_.SiteFile} */
|
||||
var config = null;
|
||||
|
||||
var SiteFile = function ( id, hash )
|
||||
var SiteFile = function ( id, hash, nObj )
|
||||
{
|
||||
if( !config ) throw new Error( "config is not defined" );
|
||||
// TODO: Make a trigger for downloading from server
|
||||
@@ -38,9 +38,14 @@
|
||||
if( stage.getAttribute( "noauto" ) != null ) return this;
|
||||
|
||||
var applyStructure = function( obj )
|
||||
{
|
||||
return _applyStructure( JSON.parse( obj ).file );
|
||||
};
|
||||
|
||||
var _applyStructure = function( obj )
|
||||
{
|
||||
/** @type {_AstJson_.SiteFile} */
|
||||
var finfo = JSON.parse( obj ).file;
|
||||
var finfo = obj;
|
||||
|
||||
switch( finfo.type )
|
||||
{
|
||||
@@ -50,16 +55,16 @@
|
||||
switch( IDOMElement(stage).getDAttribute('size') )
|
||||
{
|
||||
case "small":
|
||||
node.src = config.path.image.small + hash + '.jpg';
|
||||
node.src = finfo.thumbs.small || ( config.path.image.small + hash + '.jpg' );
|
||||
break;
|
||||
case "medium":
|
||||
node.src = config.path.image.medium + hash + '.jpg';
|
||||
node.src = finfo.thumbs.medium || ( config.path.image.medium + hash + '.jpg' );
|
||||
break;
|
||||
case "original":
|
||||
node.src = config.path.image.original + hash + '.jpg';
|
||||
break;
|
||||
default: // large
|
||||
node.src = config.path.image.large + hash + '.jpg';
|
||||
node.src = finfo.thumbs.large || ( config.path.image.large + hash + '.jpg' );
|
||||
}
|
||||
|
||||
stage.appendChild(Dand.wrapne(
|
||||
@@ -134,7 +139,14 @@
|
||||
stage.appendChild( Dand.wrapc( "sf_failed", Dand.textNode( "Error: Failed to get resources info" ) ) );
|
||||
};
|
||||
|
||||
this.loadInfo( applyStructure, loadFailed );
|
||||
if( nObj )
|
||||
{
|
||||
_applyStructure( nObj );
|
||||
}
|
||||
else
|
||||
{
|
||||
this.loadInfo( applyStructure, loadFailed );
|
||||
}
|
||||
};
|
||||
|
||||
SiteFile.prototype.loadInfo = function( success, failed )
|
||||
|
||||
Reference in New Issue
Block a user