(docId:string, content?:string)
| 2158 | }, 1, true); |
| 2159 | |
| 2160 | loadFile(docId:string, content?:string) { |
| 2161 | if(!docId) return false; |
| 2162 | if(docId === this.documentId) return false; |
| 2163 | if(this.loading) return false; |
| 2164 | |
| 2165 | // We're loading from a remote gist |
| 2166 | if(docId.indexOf("gist:") === 0 && !content) { |
| 2167 | let gistId = docId.slice(5); |
| 2168 | if(gistId.indexOf("-") !== -1) gistId = gistId.slice(0, gistId.indexOf("-")); |
| 2169 | let gistUrl = `https://gist.githubusercontent.com/raw/${gistId}`; |
| 2170 | this.loadFromGist(gistUrl); |
| 2171 | return true; |
| 2172 | } |
| 2173 | |
| 2174 | let saves = JSON.parse(localStorage.getItem("eve-saves") || "{}"); |
| 2175 | if(this.local && saves[docId]) { |
| 2176 | content = saves[docId]; |
| 2177 | this.modified = true; |
| 2178 | |
| 2179 | } else if(content) { |
| 2180 | this._fileCache[docId] = content; |
| 2181 | |
| 2182 | } else if(this._fileCache[docId]) { |
| 2183 | content = this._fileCache[docId]; |
| 2184 | this.modified = false; |
| 2185 | } |
| 2186 | |
| 2187 | if(content === undefined) { |
| 2188 | console.error(`Unable to load uncached file: '${docId}'`); |
| 2189 | return false; |
| 2190 | } |
| 2191 | this.loaded = false; |
| 2192 | this.documentId = docId; |
| 2193 | this.editor.reset(); |
| 2194 | this.notices = []; |
| 2195 | this.loading = true; |
| 2196 | this.onLoadFile(this, docId, content); |
| 2197 | |
| 2198 | return true; |
| 2199 | } |
| 2200 | |
| 2201 | loadWorkspace(directory:string, files:{[filename:string]: string}) { |
| 2202 | // @FIXME: un-hardcode root to enable multiple WS's. |
no test coverage detected