@@ -24,24 +24,6 @@ DocumentFrame.prototype.db = function(dburl){
24
24
return this ;
25
25
}
26
26
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
-
45
27
/**
46
28
* @param {String } url - loads the document frame from the document API in frame form
47
29
* - 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){
90
72
console . error ( "Either docid or clid must be set before load is called" )
91
73
}
92
74
93
- DocumentFrame . prototype . loadDataFrames = function ( dataframes , cls , classframes ) {
75
+ DocumentFrame . prototype . loadData = function ( jsonld , cls , classframes ) {
94
76
if ( ! cls ) {
95
77
if ( this . document ) cls = this . document . cls ;
96
78
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" ] ;
99
81
}
100
82
}
101
83
}
102
84
if ( cls ) {
103
85
if ( ! this . document ) {
104
- this . document = new ObjectFrame ( cls , dataframes , classframes ) ;
86
+ alert ( "Yo" )
87
+ this . document = new ObjectFrame ( cls , jsonld , classframes ) ;
105
88
}
106
89
else {
107
- this . document . loadDataFrames ( dataframes ) ;
108
- }
90
+ alert ( "Yo2" )
91
+ this . document . loadJSONLDDocument ( jsonld ) ;
92
+ }
93
+ alert ( this . document . subjid )
109
94
}
110
95
else {
111
96
console . log ( "Missing Class" + " " + "Failed to add dataframes due to missing class" ) ;
112
97
}
113
98
}
114
99
100
+ DocumentFrame . prototype . load = function ( classframes , doc ) {
101
+ this . document = new ObjectFrame ( doc [ "@type" ] , doc , classframes )
102
+ }
103
+
104
+
115
105
DocumentFrame . prototype . loadSchemaFrames = function ( classframes , cls ) {
116
106
if ( ! cls ) {
117
107
if ( classframes && classframes . length && classframes [ 0 ] && classframes [ 0 ] . domain ) {
@@ -135,6 +125,29 @@ DocumentFrame.prototype.loadSchemaFrames = function(classframes, cls){
135
125
}
136
126
}
137
127
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
+
138
151
/*
139
152
* adds render and compare functions to object frames
140
153
*/
0 commit comments