@@ -24,24 +24,6 @@ DocumentFrame.prototype.db = function(dburl){
2424 return this ;
2525}
2626
27- DocumentFrame . prototype . load = function ( url , cls ) {
28- if ( url ) {
29- if ( url . substring ( 0 , 4 ) == "doc:" ) {
30- url = url . substring ( 4 ) ;
31- }
32- if ( this . config . load_schema ( ) ) {
33- return this . loadComplete ( url , cls )
34- }
35- else {
36- return this . loadDocument ( url ) ;
37- }
38- }
39- if ( cls ) {
40- return this . loadSchema ( cls ) ;
41- }
42- //return Promise.reject
43- }
44-
4527/**
4628 * @param {String } url - loads the document frame from the document API in frame form
4729 * - loads the frame encapsulates more meta-data in the json and reduces the number of api calls we need to make
@@ -90,28 +72,36 @@ DocumentFrame.prototype.loadJSON = function(json, type){
9072 console . error ( "Either docid or clid must be set before load is called" )
9173}
9274
93- DocumentFrame . prototype . loadDataFrames = function ( dataframes , cls , classframes ) {
75+ DocumentFrame . prototype . loadData = function ( jsonld , cls , classframes ) {
9476 if ( ! cls ) {
9577 if ( this . document ) cls = this . document . cls ;
9678 else {
97- if ( dataframes && dataframes . length && dataframes [ 0 ] && dataframes [ 0 ] . domain ) {
98- cls = dataframes [ 0 ] . domain ;
79+ if ( jsonld && jsonld [ "@type" ] ) {
80+ cls = jsonld [ "@type" ] ;
9981 }
10082 }
10183 }
10284 if ( cls ) {
10385 if ( ! this . document ) {
104- this . document = new ObjectFrame ( cls , dataframes , classframes ) ;
86+ alert ( "Yo" )
87+ this . document = new ObjectFrame ( cls , jsonld , classframes ) ;
10588 }
10689 else {
107- this . document . loadDataFrames ( dataframes ) ;
108- }
90+ alert ( "Yo2" )
91+ this . document . loadJSONLDDocument ( jsonld ) ;
92+ }
93+ alert ( this . document . subjid )
10994 }
11095 else {
11196 console . log ( "Missing Class" + " " + "Failed to add dataframes due to missing class" ) ;
11297 }
11398}
11499
100+ DocumentFrame . prototype . load = function ( classframes , doc ) {
101+ this . document = new ObjectFrame ( doc [ "@type" ] , doc , classframes )
102+ }
103+
104+
115105DocumentFrame . prototype . loadSchemaFrames = function ( classframes , cls ) {
116106 if ( ! cls ) {
117107 if ( classframes && classframes . length && classframes [ 0 ] && classframes [ 0 ] . domain ) {
@@ -126,7 +116,7 @@ DocumentFrame.prototype.loadSchemaFrames = function(classframes, cls){
126116 this . document . loadClassFrames ( classframes ) ;
127117 if ( ! this . document . subjid ) {
128118 this . document . newDoc = true ;
129- this . document . fillFromSchema ( "_:" ) ;
119+ this . document . fillFromSchema ( FrameHelper . genBNID ( FrameHelper . urlFragment ( cls ) + "_" ) ) ;
130120 }
131121 }
132122 }
@@ -135,13 +125,36 @@ DocumentFrame.prototype.loadSchemaFrames = function(classframes, cls){
135125 }
136126}
137127
128+ DocumentFrame . prototype . filterFrame = function ( loadRenderer ) {
129+ var myfilt = function ( frame , rule ) {
130+ if ( typeof rule . render ( ) != "undefined" ) {
131+ frame . render = rule . render ( ) ;
132+ }
133+ else {
134+ if ( rule . renderer ( ) ) {
135+ var renderer = loadRenderer ( rule . renderer ( ) , frame , rule . args ) ;
136+ }
137+ if ( renderer ) {
138+ frame . render = function ( fframe ) {
139+ return renderer ( fframe ) ;
140+ }
141+ }
142+ }
143+ if ( rule . compare ( ) ) {
144+ frame . compare = rule . compare ( ) ;
145+ }
146+ }
147+ this . applyRules ( false , false , myfilt ) ;
148+ }
149+
150+
138151/*
139152 * adds render and compare functions to object frames
140153 */
141154DocumentFrame . prototype . applyRules = function ( doc , config , mymatch ) {
142- doc = ( doc ? doc : this . document ) ;
155+ doc = doc || this . document ;
156+ if ( ! doc ) return
143157 config = ( config ? config : this . config ) ;
144- var self = this ;
145158 var onmatch = function ( frame , rule ) {
146159 config . setFrameDisplayOptions ( frame , rule ) ;
147160 if ( mymatch ) mymatch ( frame , rule ) ;
0 commit comments