diff --git a/.gitignore b/.gitignore index a240b0f..3be6a68 100755 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,15 @@ builds/bfe.dev.bak builds/bfe.jodi.bak builds/bfe.jodi.js static/profiles/bibframe/Test All (jodiw).json +static/profiles/bibframe/profiles.json + +builds/bfe.test.js +static/js/config-test.js +static/profiles/bibframe/BIBFRAME 2.0 Test: Notated Music: Work, Expression, Instance.json +static/profiles/bibframe/Test profile (Prints & Photographs).json +test.html + + +.csslintrc +.jshintrc +.eslintrc diff --git a/Gruntfile.js b/Gruntfile.js index 16a1f0d..b59b46a 100755 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -38,7 +38,7 @@ module.exports = function(grunt) { } }); - grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-contrib-uglify-es'); grunt.loadNpmTasks('grunt-contrib-cssmin'); grunt.loadNpmTasks('grunt-contrib-concat'); diff --git a/build_support/mini_require.js b/build_support/mini_require.js index cc59000..06bf088 100755 --- a/build_support/mini_require.js +++ b/build_support/mini_require.js @@ -1,197 +1,171 @@ -/* - kefo: Copied from Ace editor repository. This file is needed - to hook up the requirejs defines so they work with a defined - javascript bfe namespace since we use dryice to build and not requirejs. - https://github.com/ajaxorg/ace/blob/master/build_support/mini_require.js - - Beyond the note above, it is not used in any other way. It is only - invoked when building/minifying the code. -*/ - -/* ***** BEGIN LICENSE BLOCK ***** - * Distributed under the BSD license: - * - * Copyright (c) 2010, Ajax.org B.V. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of Ajax.org B.V. nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * ***** END LICENSE BLOCK ***** */ - -/** - * Define a module along with a payload - * @param module a name for the payload - * @param payload a function to call with (require, exports, module) params - */ - -(function() { - -var ACE_NAMESPACE = "bfe"; - -var global = (function() { - return this; -})(); - - -if (!ACE_NAMESPACE && typeof requirejs !== "undefined") - return; - - -var _define = function(module, deps, payload) { - if (typeof module !== 'string') { - if (_define.original) - _define.original.apply(window, arguments); - else { - console.error('dropping module because define wasn\'t a string.'); - console.trace(); - } - return; - } - - if (arguments.length == 2) - payload = deps; - - if (!_define.modules) { - _define.modules = {}; - _define.payloads = {}; - } - - _define.payloads[module] = payload; - _define.modules[module] = null; -}; - -/** - * Get at functionality define()ed using the function above - */ -var _require = function(parentId, module, callback) { - if (Object.prototype.toString.call(module) === "[object Array]") { - var params = []; - for (var i = 0, l = module.length; i < l; ++i) { - var dep = lookup(parentId, module[i]); - if (!dep && _require.original) - return _require.original.apply(window, arguments); - params.push(dep); - } - if (callback) { - callback.apply(null, params); - } - } - else if (typeof module === 'string') { - var payload = lookup(parentId, module); - if (!payload && _require.original) - return _require.original.apply(window, arguments); - - if (callback) { - callback(); - } - - return payload; - } - else { - if (_require.original) - return _require.original.apply(window, arguments); - } -}; - -var normalizeModule = function(parentId, moduleName) { - // normalize plugin requires - if (moduleName.indexOf("!") !== -1) { - var chunks = moduleName.split("!"); - return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); - } - // normalize relative requires - if (moduleName.charAt(0) == ".") { - var base = parentId.split("/").slice(0, -1).join("/"); - moduleName = base + "/" + moduleName; - - while(moduleName.indexOf(".") !== -1 && previous != moduleName) { - var previous = moduleName; - moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); - } - } - - return moduleName; -}; - -/** - * Internal function to lookup moduleNames and resolve them by calling the - * definition function if needed. - */ -var lookup = function(parentId, moduleName) { - - moduleName = normalizeModule(parentId, moduleName); - - var module = _define.modules[moduleName]; - if (!module) { - module = _define.payloads[moduleName]; - if (typeof module === 'function') { - var exports = {}; - var mod = { - id: moduleName, - uri: '', - exports: exports, - packaged: true - }; - - var req = function(module, callback) { - return _require(moduleName, module, callback); - }; - - var returnValue = module(req, exports, mod); - exports = returnValue || mod.exports; - _define.modules[moduleName] = exports; - delete _define.payloads[moduleName]; - } - module = _define.modules[moduleName] = exports || module; - } - return module; -}; - -function exportAce(ns) { - var require = function(module, callback) { - return _require("", module, callback); - }; - - var root = global; - if (ns) { - if (!global[ns]) - global[ns] = {}; - root = global[ns]; - } - - if (!root.define || !root.define.packaged) { - _define.original = root.define; - root.define = _define; - root.define.packaged = true; - } - - if (!root.require || !root.require.packaged) { - _require.original = root.require; - root.require = require; - root.require.packaged = true; - } -} - -exportAce(ACE_NAMESPACE); - -})(); +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ +/** + * Define a module along with a payload + * @param module a name for the payload + * @param payload a function to call with (require, exports, module) params + */ +(function () { + var ACE_NAMESPACE = 'bfe'; + + var global = (function () { + return this; + })(); + + if (!ACE_NAMESPACE && typeof requirejs !== 'undefined') { return; } + + var _define = function (module, deps, payload) { + if (typeof module !== 'string') { + if (_define.original) { _define.original.apply(window, arguments); } else { + console.error('dropping module because define wasn\'t a string.'); + console.trace(); + } + return; + } + + if (arguments.length === 2) { payload = deps; } + + if (!_define.modules) { + _define.modules = {}; + _define.payloads = {}; + } + + _define.payloads[module] = payload; + _define.modules[module] = null; + }; + + /** + * Get at functionality define()ed using the function above + */ + var _require = function (parentId, module, callback) { + if (Object.prototype.toString.call(module) === '[object Array]') { + var params = []; + for (var i = 0, l = module.length; i < l; ++i) { + var dep = lookup(parentId, module[i]); + if (!dep && _require.original) { return _require.original.apply(window, arguments); } + params.push(dep); + } + if (callback) { + callback.apply(null, params); + } + } else if (typeof module === 'string') { + var payload = lookup(parentId, module); + if (!payload && _require.original) { return _require.original.apply(window, arguments); } + + if (callback) { + callback(); + } + + return payload; + } else { + if (_require.original) { return _require.original.apply(window, arguments); } + } + }; + + var normalizeModule = function (parentId, moduleName) { + // normalize plugin requires + if (moduleName.indexOf('!') !== -1) { + var chunks = moduleName.split('!'); + return normalizeModule(parentId, chunks[0]) + '!' + normalizeModule(parentId, chunks[1]); + } + // normalize relative requires + if (moduleName.charAt(0) === '.') { + var base = parentId.split('/').slice(0, -1).join('/'); + moduleName = base + '/' + moduleName; + + while (moduleName.indexOf('.') !== -1 && previous !== moduleName) { + var previous = moduleName; + moduleName = moduleName.replace(/\/\.\//, '/').replace(/[^\/]+\/\.\.\//, ''); + } + } + + return moduleName; + }; + + /** + * Internal function to lookup moduleNames and resolve them by calling the + * definition function if needed. + */ + var lookup = function (parentId, moduleName) { + moduleName = normalizeModule(parentId, moduleName); + var exports; + var module = _define.modules[moduleName]; + if (!module) { + module = _define.payloads[moduleName]; + if (typeof module === 'function') { + exports = {}; + var mod = { + id: moduleName, + uri: '', + exports: exports, + packaged: true + }; + + var req = function (module, callback) { + return _require(moduleName, module, callback); + }; + + var returnValue = module(req, exports, mod); + exports = returnValue || mod.exports; + _define.modules[moduleName] = exports; + delete _define.payloads[moduleName]; + } + module = _define.modules[moduleName] = exports || module; + } + return module; + }; + + function exportAce (ns) { + var require = function (module, callback) { + return _require('', module, callback); + }; + + var root = global; + if (ns) { + if (!global[ns]) { global[ns] = {}; } + root = global[ns]; + } + + if (!root.define || !root.define.packaged) { + _define.original = root.define; + root.define = _define; + root.define.packaged = true; + } + + if (!root.require || !root.require.packaged) { + _require.original = root.require; + root.require = require; + root.require.packaged = true; + } + } + + exportAce(ACE_NAMESPACE); + })(); + \ No newline at end of file diff --git a/builds/bfe.css b/builds/bfe.css index c0da310..e3b1c33 100755 --- a/builds/bfe.css +++ b/builds/bfe.css @@ -1,4 +1,4 @@ -/* bfe 2015-10-26 *//*! +/* bfe 2018-09-18 *//*! * Bootstrap v3.1.1 (http://getbootstrap.com) * Copyright 2011-2014 Twitter, Inc. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) diff --git a/builds/bfe.dev.js b/builds/bfe.dev.js index 11dc368..0355d47 100755 --- a/builds/bfe.dev.js +++ b/builds/bfe.dev.js @@ -1,10 +1,9 @@ -/* bfe 2018-01-29 */ /* ***** BEGIN LICENSE BLOCK ***** * Distributed under the BSD license: * * Copyright (c) 2010, Ajax.org B.V. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright @@ -15,7 +14,7 @@ * * Neither the name of Ajax.org B.V. nor the * names of its contributors may be used to endorse or promote products * derived from this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -33,499 +32,514 @@ * @param module a name for the payload * @param payload a function to call with (require, exports, module) params */ -(function() { - - var ACE_NAMESPACE = "bfe"; - - var global = (function() { - return this; - })(); - - - if (!ACE_NAMESPACE && typeof requirejs !== "undefined") - return; - - - var _define = function(module, deps, payload) { - if (typeof module !== 'string') { - if (_define.original) - _define.original.apply(window, arguments); - else { - console.error('dropping module because define wasn\'t a string.'); - console.trace(); - } - return; - } +(function () { + var ACE_NAMESPACE = 'bfe'; + + var global = (function () { + return this; + })(); + + if (!ACE_NAMESPACE && typeof requirejs !== 'undefined') { return; } + + var _define = function (module, deps, payload) { + if (typeof module !== 'string') { + if (_define.original) { _define.original.apply(window, arguments); } else { + console.error('dropping module because define wasn\'t a string.'); + console.trace(); + } + return; + } - if (arguments.length === 2) - payload = deps; + if (arguments.length === 2) { payload = deps; } - if (!_define.modules) { - _define.modules = {}; - _define.payloads = {}; - } + if (!_define.modules) { + _define.modules = {}; + _define.payloads = {}; + } - _define.payloads[module] = payload; - _define.modules[module] = null; - }; + _define.payloads[module] = payload; + _define.modules[module] = null; + }; /** * Get at functionality define()ed using the function above */ - var _require = function(parentId, module, callback) { - if (Object.prototype.toString.call(module) === "[object Array]") { - var params = []; - for (var i = 0, l = module.length; i < l; ++i) { - var dep = lookup(parentId, module[i]); - if (!dep && _require.original) - return _require.original.apply(window, arguments); - params.push(dep); - } - if (callback) { - callback.apply(null, params); - } - } else if (typeof module === 'string') { - var payload = lookup(parentId, module); - if (!payload && _require.original) - return _require.original.apply(window, arguments); - - if (callback) { - callback(); - } - - return payload; - } else { - if (_require.original) - return _require.original.apply(window, arguments); - } - }; + var _require = function (parentId, module, callback) { + if (Object.prototype.toString.call(module) === '[object Array]') { + var params = []; + for (var i = 0, l = module.length; i < l; ++i) { + var dep = lookup(parentId, module[i]); + if (!dep && _require.original) { return _require.original.apply(window, arguments); } + params.push(dep); + } + if (callback) { + callback.apply(null, params); + } + } else if (typeof module === 'string') { + var payload = lookup(parentId, module); + if (!payload && _require.original) { return _require.original.apply(window, arguments); } + + if (callback) { + callback(); + } + + return payload; + } else { + if (_require.original) { return _require.original.apply(window, arguments); } + } + }; - var normalizeModule = function(parentId, moduleName) { - // normalize plugin requires - if (moduleName.indexOf("!") !== -1) { - var chunks = moduleName.split("!"); - return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); - } - // normalize relative requires - if (moduleName.charAt(0) === ".") { - var base = parentId.split("/").slice(0, -1).join("/"); - moduleName = base + "/" + moduleName; - - while (moduleName.indexOf(".") !== -1 && previous !== moduleName) { - var previous = moduleName; - moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); - } - } + var normalizeModule = function (parentId, moduleName) { + // normalize plugin requires + if (moduleName.indexOf('!') !== -1) { + var chunks = moduleName.split('!'); + return normalizeModule(parentId, chunks[0]) + '!' + normalizeModule(parentId, chunks[1]); + } + // normalize relative requires + if (moduleName.charAt(0) === '.') { + var base = parentId.split('/').slice(0, -1).join('/'); + moduleName = base + '/' + moduleName; + + while (moduleName.indexOf('.') !== -1 && previous !== moduleName) { + var previous = moduleName; + moduleName = moduleName.replace(/\/\.\//, '/').replace(/[^\/]+\/\.\.\//, ''); + } + } - return moduleName; - }; + return moduleName; + }; /** * Internal function to lookup moduleNames and resolve them by calling the * definition function if needed. */ - var lookup = function(parentId, moduleName) { - - moduleName = normalizeModule(parentId, moduleName); - - var module = _define.modules[moduleName]; - if (!module) { - module = _define.payloads[moduleName]; - if (typeof module === 'function') { - var exports = {}; - var mod = { - id: moduleName, - uri: '', - exports: exports, - packaged: true - }; - - var req = function(module, callback) { - return _require(moduleName, module, callback); - }; - - var returnValue = module(req, exports, mod); - exports = returnValue || mod.exports; - _define.modules[moduleName] = exports; - delete _define.payloads[moduleName]; - } - module = _define.modules[moduleName] = exports || module; - } - return module; - }; - - function exportAce(ns) { - var require = function(module, callback) { - return _require("", module, callback); + var lookup = function (parentId, moduleName) { + moduleName = normalizeModule(parentId, moduleName); + var exports; + var module = _define.modules[moduleName]; + if (!module) { + module = _define.payloads[moduleName]; + if (typeof module === 'function') { + exports = {}; + var mod = { + id: moduleName, + uri: '', + exports: exports, + packaged: true }; - var root = global; - if (ns) { - if (!global[ns]) - global[ns] = {}; - root = global[ns]; - } - - if (!root.define || !root.define.packaged) { - _define.original = root.define; - root.define = _define; - root.define.packaged = true; - } + var req = function (module, callback) { + return _require(moduleName, module, callback); + }; - if (!root.require || !root.require.packaged) { - _require.original = root.require; - root.require = require; - root.require.packaged = true; - } + var returnValue = module(req, exports, mod); + exports = returnValue || mod.exports; + _define.modules[moduleName] = exports; + delete _define.payloads[moduleName]; + } + module = _define.modules[moduleName] = exports || module; } + return module; + }; - exportAce(ACE_NAMESPACE); - -})(); - -bfe.define('src/bfe', ['require', 'exports', 'module', 'src/bfestore', 'src/bfelogging', 'src/lib/aceconfig'], function(require, exports, module) { - var editorconfig = {}; - var bfestore = require("src/bfestore"); - var bfelog = require("src/bfelogging"); - //var store = new rdfstore.Store(); - var profiles = []; - var resourceTemplates = []; - var startingPoints = []; - var formTemplates = []; - //var lookups = []; - - var tabIndices = 1; - - //var loadtemplates = []; - var loadtemplatesANDlookupsCount = 0; - var loadtemplatesANDlookupsCounter = 0; + function exportAce (ns) { + var require = function (module, callback) { + return _require('', module, callback); + }; - var lookupstore = []; - var lookupcache = []; + var root = global; + if (ns) { + if (!global[ns]) { global[ns] = {}; } + root = global[ns]; + } - var editordiv; + if (!root.define || !root.define.packaged) { + _define.original = root.define; + root.define = _define; + root.define.packaged = true; + } - var csrf; + if (!root.require || !root.require.packaged) { + _require.original = root.require; + root.require = require; + root.require.packaged = true; + } + } - var forms = []; + exportAce(ACE_NAMESPACE); +})(); - var lookups = { - "http://id.loc.gov/authorities/names": { - "name": "LCNAF", - "load": require("src/lookups/lcnames") - }, - "http://id.loc.gov/authorities/subjects": { - "name": "LCSH", - "load": require("src/lookups/lcsubjects") - }, - "http://id.loc.gov/authorities/genreForms": { - "name": "LCGFT", - "load": require("src/lookups/lcgenreforms") - }, - "http://id.loc.gov/resources/works": { - "name": "LC-Works", - "load": require("src/lookups/lcworks") - }, - "http://id.loc.gov/resources/instances": { - "name": "LC-Instances", - "load": require("src/lookups/lcinstances") - }, - "http://id.loc.gov/vocabulary/organizations": { - "name": "Organizations", - "load": require("src/lookups/lcorganizations") - }, - "http://id.loc.gov/vocabulary/relators": { - "name": "Relators", - "load": require("src/lookups/relators") - }, - "http://rdaregistry.info/termList/FormatNoteMus": { - "name": "RDA-Format-Musical-Notation", - "load": require("src/lookups/rdaformatnotemus") - }, - "http://rdaregistry.info/termList/RDAMediaType": { - "name": "RDA-Media-Type", - "load": require("src/lookups/rdamediatype") - }, - "http://rdaregistry.info/termList/ModeIssue": { - "name": "RDA-Mode-Issue", - "load": require("src/lookups/rdamodeissue") - }, - "http://rdaregistry.info/termList/RDACarrierType": { - "name": "RDA-Carrier-Type", - "load": require("src/lookups/rdacarriertype") - }, - "http://rdaregistry.info/termList/RDAContentType": { - "name": "RDA-Content-Type", - "load": require("src/lookups/rdacontenttype") - }, - "http://rdaregistry.info/termList/frequency": { - "name": "RDA-Frequency", - "load": require("src/lookups/rdafrequency") - }, - "http://www.rdaregistry.info/termList/AspectRatio": { - "name": "RDA-Aspect-Ratio", - "load": require("src/lookups/rdaaspectration") - }, - "http://www.rdaregistry.info/termList/RDAGeneration": { - "name": "RDA-Generation", - "load": require("src/lookups/rdageneration") - } - }; +bfe.define('src/bfe', ['require', 'exports', 'module', 'src/bfestore', 'src/bfelogging', 'src/lib/aceconfig'], function (require, exports, module) { + var editorconfig = {}; + var bfestore = require('src/bfestore'); + var bfelog = require('src/bfelogging'); + // var store = new rdfstore.Store(); + var profiles = []; + var resourceTemplates = []; + var addFields = {}; + var addedProperties = []; + // var startingPoints = []; + // var formTemplates = []; + // var lookups = []; + + var tabIndices = 1; + + // var loadtemplates = []; + var loadtemplatesANDlookupsCount = 0; + var loadtemplatesANDlookupsCounter = 0; + + // var lookupstore = []; + // var lookupcache = []; + + var editordiv; + + // var csrf; + + var forms = []; + + var lookups = { + 'http://id.loc.gov/authorities/names': { + 'name': 'LCNAF', + 'load': require('src/lookups/lcnames') + }, + 'http://id.loc.gov/authorities/subjects': { + 'name': 'LCSH', + 'load': require('src/lookups/lcsubjects') + }, + 'http://id.loc.gov/authorities/genreForms': { + 'name': 'LCGFT', + 'load': require('src/lookups/lcgenreforms') + }, + 'http://id.loc.gov/resources/works': { + 'name': 'LC-Works', + 'load': require('src/lookups/lcworks') + }, + 'http://id.loc.gov/resources/instances': { + 'name': 'LC-Instances', + 'load': require('src/lookups/lcinstances') + }, + 'http://id.loc.gov/vocabulary/organizations': { + 'name': 'Organizations', + 'load': require('src/lookups/lcorganizations') + }, + 'http://id.loc.gov/vocabulary/relators': { + 'name': 'Relators', + 'load': require('src/lookups/relators') + }, + 'http://rdaregistry.info/termList/FormatNoteMus': { + 'name': 'RDA-Format-Musical-Notation', + 'load': require('src/lookups/rdaformatnotemus') + }, + 'http://rdaregistry.info/termList/RDAMediaType': { + 'name': 'RDA-Media-Type', + 'load': require('src/lookups/rdamediatype') + }, + 'http://rdaregistry.info/termList/ModeIssue': { + 'name': 'RDA-Mode-Issue', + 'load': require('src/lookups/rdamodeissue') + }, + 'http://rdaregistry.info/termList/RDACarrierType': { + 'name': 'RDA-Carrier-Type', + 'load': require('src/lookups/rdacarriertype') + }, + 'http://rdaregistry.info/termList/RDAContentType': { + 'name': 'RDA-Content-Type', + 'load': require('src/lookups/rdacontenttype') + }, + 'http://rdaregistry.info/termList/frequency': { + 'name': 'RDA-Frequency', + 'load': require('src/lookups/rdafrequency') + }, + 'http://www.rdaregistry.info/termList/AspectRatio': { + 'name': 'RDA-Aspect-Ratio', + 'load': require('src/lookups/rdaaspectration') + }, + 'http://www.rdaregistry.info/termList/RDAGeneration': { + 'name': 'RDA-Generation', + 'load': require('src/lookups/rdageneration') + } + }; /* The following two bits of code come from the Ace Editor code base. Included here to make 'building' work correctly. See: https://github.com/ajaxorg/ace/blob/master/lib/ace/ace.js */ - exports.aceconfig = require("src/lib/aceconfig"); - /** + exports.aceconfig = require('src/lib/aceconfig'); + /** * Provides access to require in packed noconflict mode * @param {String} moduleName * @returns {Object} * **/ - exports.require = require; - - exports.setConfig = function(config) { - - editorconfig = config; - - // Set up logging - bfelog.init(editorconfig); - - for (var i = 0; i < config.profiles.length; i++) { - var file = config.profiles[i]; - bfelog.addMsg(new Error(), "INFO", "Loading profile: " + config.profiles[i]); - $.ajax({ - type: "GET", - dataType: "json", - async: false, - url: file, - success: function(data) { - $("#bfeditor-loader").width($("#bfeditor-loader").width() + 5 + "%"); - profiles.push(data); - for (var rt = 0; rt < data.Profile.resourceTemplates.length; rt++) { - resourceTemplates.push(data.Profile.resourceTemplates[rt]); - } - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - bfelog.addMsg(new Error(), "ERROR", "FAILED to load profile: " + file); - bfelog.addMsg(new Error(), "ERROR", "Request status: " + textStatus + "; Error msg: " + errorThrown); - } - }); - } + exports.require = require; - if (config.lookups !== undefined) { - loadtemplatesANDlookupsCount = loadtemplatesANDlookupsCount + Object.keys(config.lookups).length; - config.lookups.foreach(function(lu) { - bfelog.addMsg(new Error(), "INFO", "Loading lookup: " + lu.load); - require([lu.load], function(r) { - setLookup(r); - }); - }); - } - if (editorconfig.baseURI === undefined) { - editorconfig.baseURI = window.location.protocol + "//" + window.location.host + "/"; - } - bfelog.addMsg(new Error(), "INFO", "baseURI is " + editorconfig.baseURI); - - if (config.load !== undefined) { - loadtemplatesANDlookupsCount = loadtemplatesANDlookupsCount + config.load.length; - config.load.forEach(function(l) { - var tempstore = []; - l.templateID.forEach(function(lt) { - var useguid = guid(); - var loadtemplate = {}; - loadtemplate.templateGUID = useguid; - loadtemplate.resourceTemplateID = lt; - loadtemplate.resourceURI = l.defaulturi; - loadtemplate.embedType = "page"; - loadtemplate.data = tempstore; - loadtemplates.push(loadtemplate); - }); - if (l.source !== undefined && l.source.location !== undefined && l.source.requestType !== undefined) { - $.ajax({ - url: l.source.location, - dataType: l.source.requestType, - success: function(data) { - bfelog.addMsg(new Error(), "INFO", "Fetched external source baseURI" + l.source.location); - bfelog.addMsg(new Error(), "DEBUG", "Source data", data); - - tempstore = bfestore.jsonld2store(data); - //loadtemplate.data = tempstore; - cbLoadTemplates(); - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - bfelog.addMsg(new Error(), "ERROR", "FAILED to load external source: " + l.source.location); - bfelog.addMsg(new Error(), "ERROR", "Request status: " + textStatus + "; Error msg: " + errorThrown); - } - }); + exports.setConfig = function (config) { + editorconfig = config; + + // Set up logging + bfelog.init(editorconfig); + + /** + * Profiles are expected to be in the form provided by Verso: + * A JSON Array of objects with a "json" property that contains the profile proper + **/ + for (var i = 0; i < config.profiles.length; i++) { + var file = config.profiles[i]; + $.ajax({ + type: 'GET', + dataType: 'json', + url: file, + error: function (XMLHttpRequest, textStatus, errorThrown) { + bfelog.addMsg(new Error(), 'ERROR', 'FAILED to load profile: ' + file); + bfelog.addMsg(new Error(), 'ERROR', 'Request status: ' + textStatus + '; Error msg: ' + errorThrown); + }, + complete: function (jqXHR, textStatus) { + if (textStatus == 'success') { + var data = JSON.parse(jqXHR.responseText); + $('#bfeditor-loader').width($('#bfeditor-loader').width() + 5 + '%'); + + if (data.length > 0) { + for (var j = 0; j < data.length; j++) { + profiles.push(data[j].json); + for (var rt = 0; rt < data[j].json.Profile.resourceTemplates.length; rt++) { + resourceTemplates.push(data[j].json.Profile.resourceTemplates[rt]); + // populate addFields hash with property templates for the "add property" function. + data[j].json.Profile.resourceTemplates[rt].propertyTemplates.forEach(function(ptemp) { + if (ptemp.type != 'resource') { + if (ptemp.propertyLabel !== undefined) { + var propKey = ptemp.propertyLabel; + propKey = propKey.replace(/^\d\w*\. /,''); + addFields[propKey] = ptemp; + } + } + }) - } else { - cbLoadTemplates(); } - }); + bfelog.addMsg(new Error(), 'INFO', 'Loaded profile: ' + data[j].name); + } + } else { + bfelog.addMsg(new Error(), 'ERROR', 'No profiles loaded from ' + this.url + ' (empty result set)'); + } + } } + }); + } - }; - - exports.fulleditor = function(config, id) { - - editordiv = document.getElementById(id); - var $containerdiv = $('

Bibframe Editor Workspace

'); - var $tabul = $(''); - $tabul.append('
  • Browse
  • '); - $tabul.append('
  • Editor
  • '); - $tabul.append('
  • Load Work
  • '); - $tabul.append('
  • Load IBC
  • '); - $containerdiv.append($tabul); - - var $tabcontentdiv = $('
    '); - var $browsediv = $('

    '); - var $creatediv = $('

    '); - var $loaddiv = $('

    '); - var $loadibcdiv = $('

    '); - - var $menudiv = $('
    ', { - id: "bfeditor-menudiv", - class: "col-md-2 sidebar" - }); - var $formdiv = $('
    ', { - id: "bfeditor-formdiv", - class: "col-md-10 main" + if (config.lookups !== undefined) { + loadtemplatesANDlookupsCount = loadtemplatesANDlookupsCount + Object.keys(config.lookups).length; + config.lookups.foreach(function (lu) { + bfelog.addMsg(new Error(), 'INFO', 'Loading lookup: ' + lu.load); + require([lu.load], function (r) { + setLookup(r); }); - //var optiondiv = $('
    ', {id: "bfeditor-optiondiv", class: "col-md-2"}); - var $rowdiv = $('
    ', { - class: "row" + }); + } + if (editorconfig.baseURI === undefined) { + editorconfig.baseURI = window.location.protocol + '//' + window.location.host + '/'; + } + bfelog.addMsg(new Error(), 'INFO', 'baseURI is ' + editorconfig.baseURI); + + if (config.load !== undefined) { + loadtemplatesANDlookupsCount = loadtemplatesANDlookupsCount + config.load.length; + config.load.forEach(function (l) { + var tempstore = []; + l.templateID.forEach(function (lt) { + var useguid = guid(); + var loadtemplate = {}; + loadtemplate.templateGUID = useguid; + loadtemplate.resourceTemplateID = lt; + loadtemplate.resourceURI = l.defaulturi; + loadtemplate.embedType = 'page'; + loadtemplate.data = tempstore; + loadtemplates.push(loadtemplate); }); + if (l.source !== undefined && l.source.location !== undefined && l.source.requestType !== undefined) { + $.ajax({ + url: l.source.location, + dataType: l.source.requestType, + success: function (data) { + bfelog.addMsg(new Error(), 'INFO', 'Fetched external source baseURI' + l.source.location); + bfelog.addMsg(new Error(), 'DEBUG', 'Source data', data); + + tempstore = bfestore.jsonld2store(data); + // loadtemplate.data = tempstore; + cbLoadTemplates(); + }, + error: function (XMLHttpRequest, textStatus, errorThrown) { + bfelog.addMsg(new Error(), 'ERROR', 'FAILED to load external source: ' + l.source.location); + bfelog.addMsg(new Error(), 'ERROR', 'Request status: ' + textStatus + '; Error msg: ' + errorThrown); + } + }); + } else { + cbLoadTemplates(); + } + }); + } + }; + + exports.fulleditor = function (config, id) { + editordiv = document.getElementById(id); + var $containerdiv = $('

    Bibframe Editor Workspace

    '); + var $tabuldiv = $('
    '); + var $tabul = $(''); + $tabul.append('
  • Browse
  • '); + $tabul.append('
  • Editor
  • '); + $tabul.append('
  • Load Work
  • '); + $tabul.append('
  • Load IBC
  • '); + $tabul.append('
  • Load MARC
  • '); + + $tabuldiv.append($tabul); + $containerdiv.append($tabuldiv); + + var $tabcontentdiv = $('
    '); + var $browsediv = $('

    '); + var $creatediv = $('

    '); + var $loadworkdiv = $('

    '); + var $loadibcdiv = $('

    '); + var $loadmarcdiv = $('

    '); + + var $menudiv = $('
    ', { + id: 'bfeditor-menudiv', + class: 'col-md-2 sidebar' + }); + var $formdiv = $('
    ', { + id: 'bfeditor-formdiv', + class: 'col-md-10 main' + }); + // var optiondiv = $('
    ', {id: "bfeditor-optiondiv", class: "col-md-2"}); + var $rowdiv = $('
    ', { + class: 'row' + }); - var $loader = $('


    Loading...

    \ + var $loader = $('


    Loading...

    \
    \ 80% Complete\
    \
    '); - if ($.fn.dataTable.isDataTable('#table_id')) { - var table = $('#table_id').DataTable(); - } else { - var $datatable = $('
    idnametitleLCCNcommentmodifiededit
    '); - var table = $(function() { - $('#table_id').DataTable({ - "initComplete": function (settings, json) { - if (window.location.hash !== ""){ - $('#table_id').DataTable().search(window.location.hash.split("#")[1]).draw(); - } - }, - "processing": true, - "paging": true, - "ajax": { - "url": config.url + "/verso/api/bfs", - "dataSrc": "", - "headers": { - 'Access-Control-Allow-Origin': '*', - 'Content-Type':'application/json', - 'Access-Control-Allow-Methods': 'DELETE, HEAD, GET, OPTIONS, POST, PUT', - 'Access-Control-Allow-Headers': 'Content-Type, Content-Range, Content-Disposition, Content-Description', - 'Access-Control-Max-Age': '1728000' - } - }, - "columns": [{ - "data": "id" - }, - { - "data": "name", - "render": function(data, type, full, meta){ - try { - - retval = mintResource(data); - - if (retval === "eundefined"){ - retval = data; - } - - } catch (e) { + var table = $('#table_id').DataTable(); + if (!$.fn.dataTable.isDataTable('#table_id')) { + var $datatable = $('
    idnametitleLCCNcommentmodifiededit
    '); + table = $(function () { + $('#table_id').DataTable({ + 'initComplete': function (settings, json) { + if (window.location.hash !== '') { + $('#table_id').DataTable().search(window.location.hash.split('#')[1]).draw(); + } + }, + 'processing': true, + 'paging': true, + 'ajax': { + 'url': config.url + '/verso/api/bfs', + 'dataSrc': '', + 'headers': { + 'Access-Control-Allow-Origin': '*', + //'Content-Type': 'application/json', + //'Accept': 'application/json', + 'Access-Control-Allow-Methods': 'DELETE, HEAD, GET, OPTIONS, POST, PUT', + 'Access-Control-Allow-Headers': 'Content-Type, Content-Range, Content-Disposition, Content-Description', + 'Access-Control-Max-Age': '1728000' + } + }, + // id + 'columns': [{ + 'data': 'id' + }, + // name + { + 'data': 'name', + 'render': function (data, type, full, meta) { + try { + retval = mintResource(data); + + if (retval === 'eundefined') { + retval = data; + } + } catch (e) { + retval = data; + } - retval = data; + return retval; + } + }, + // title + { + 'data': 'rdf', + 'render': function (data, type, full, meta) { + var retval = 'No Title'; + if (_.some(data, 'http://id.loc.gov/ontologies/bibframe/title')) { + text = _.find(data, 'http://id.loc.gov/ontologies/bibframe/title')['http://id.loc.gov/ontologies/bibframe/title']; + // return text["http://id.loc.gov/ontologies/bibframe/title"][0]["@value"]; + if (text !== undefined) { + _.each(text, function (el) { + if (el['@id'] !== undefined) { + id = el['@id']; + title = _.where(data, { + '@id': id + }); + + if (_.has(title[0], 'http://id.loc.gov/ontologies/bibframe/mainTitle')) { retval = title[0]['http://id.loc.gov/ontologies/bibframe/mainTitle'][0]['@value']; } else if (_.has(title[0], 'http://www.w3.org/2000/01/rdf-schema#label')) { retval = title[0]['http://www.w3.org/2000/01/rdf-schema#label'][0]['@value']; } + } + }); + } + } else if (_.some(data, 'http://www.loc.gov/mads/rdf/v1#authoritativeLabel')) { + retval = _.find(data, 'http://www.loc.gov/mads/rdf/v1#authoritativeLabel')['http://www.loc.gov/mads/rdf/v1#authoritativeLabel'][0]['@value']; + if (retval === undefined) { retval = _.find(data, 'http://www.loc.gov/mads/rdf/v1#authoritativeLabel')['http://www.w3.org/2000/01/rdf-schema#label'][0]['@value']; } + } else { + retval = 'No Title'; + } + return retval; + } + }, + // lccn + { + 'data': 'rdf', + 'render': function (data, type, full, meta) { + var text = 'N/A'; + var lccns = _.filter(data, function (el) { + if (!_.isEmpty(el['@type'])) { + if (el['@type'][0].match('^(http|https):\/\/id\.loc\.gov\/ontologies\/bibframe\/Lccn')) { + if (_.has(el, ['http://www.w3.org/1999/02/22-rdf-syntax-ns#value'])) { + if (!_.isEmpty(el['http://www.w3.org/1999/02/22-rdf-syntax-ns#value'][0]['@value'])) { return el['http://www.w3.org/1999/02/22-rdf-syntax-ns#value'][0]['@value']; } + } + } + } + }); + if (!_.isEmpty(lccns)) { + if (lccns.length === 1) { + text = lccns[0]['http://www.w3.org/1999/02/22-rdf-syntax-ns#value'][0]['@value']; + } else { + for (i = 0; i < lccns.length; i++) { + if (!lccns[i]['http://www.w3.org/1999/02/22-rdf-syntax-ns#value'][0]['@value'].startsWith('n')) { text = lccns[i]['http://www.w3.org/1999/02/22-rdf-syntax-ns#value'][0]['@value']; } + } + } + } + // console.log(full.id); + if (text !== 'N/A' && full.status === 'published' || full.status === 'success') { + var ldsurl = config.basedbURI + '/loc.natlib.instances.e' + text.trim() + '0001'; - } + if (text.trim().startsWith('n')) { + ldsurl = config.basedbURI + '/loc.natlib.works.' + text.trim().replace(/\s+/g, ''); + } - return retval; - } - }, - { - "data": "rdf", - "render": function(data, type, full, meta) { - var retval = "No Title"; - if (_.some(data, "http://id.loc.gov/ontologies/bibframe/title")) { - text = _.find(data, "http://id.loc.gov/ontologies/bibframe/title")["http://id.loc.gov/ontologies/bibframe/title"]; - //return text["http://id.loc.gov/ontologies/bibframe/title"][0]["@value"]; - if (text !== undefined) - _.each(text, function(el){ - if (el["@id"] !== undefined) { - id = el["@id"] - title = _.where(data, { - "@id": id - }); - - if (_.has(title[0], "http://id.loc.gov/ontologies/bibframe/mainTitle")) - retval = title[0]["http://id.loc.gov/ontologies/bibframe/mainTitle"][0]["@value"]; - else if (_.has(title[0], "http://www.w3.org/2000/01/rdf-schema#label")) - retval = title[0]["http://www.w3.org/2000/01/rdf-schema#label"][0]["@value"]; - } - }); - } else if (_.some(data, "http://www.loc.gov/mads/rdf/v1#authoritativeLabel")) { - retval = _.find(data, "http://www.loc.gov/mads/rdf/v1#authoritativeLabel")["http://www.loc.gov/mads/rdf/v1#authoritativeLabel"][0]["@value"] - if (retval === undefined) - retval = _.find(data, "http://www.loc.gov/mads/rdf/v1#authoritativeLabel")["http://www.w3.org/2000/01/rdf-schema#label"][0]["@value"] - } else { - retval = "No Title"; - } - return retval; - } - }, - { - "data": "rdf", - "render": function(data, type, full, meta) { - var text = "N/A"; - var lccns = _.filter(data, function(el) { - if (!_.isEmpty(el["@type"])){ - if (el["@type"][0] === "http://id.loc.gov/ontologies/bibframe/Lccn"){ - if (_.has(el, ["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"])) - if (!_.isEmpty(el["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"][0]["@value"])) - return el["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"][0]["@value"]; - } - } - }); - if (!_.isEmpty(lccns)){ - if (lccns.length === 1) { - text = lccns[0]["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"][0]["@value"]; - } else { - for(i=0; i < lccns.length; i++){ - if (!lccns[i]["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"][0]["@value"].startsWith("n")) - text = lccns[i]["http://www.w3.org/1999/02/22-rdf-syntax-ns#value"][0]["@value"]; - } - } - } - console.log(full.id); - if (text !== "N/A" && full.status === "published" || full.status === "success"){ - var ldsurl = config.basedbURI + "/loc.natlib.instances.e" + text.trim() + "0001"; - - if (text.trim().startsWith("n")){ - ldsurl = config.basedbURI + "/loc.natlib.works." + text.trim().replace(/\s+/g,''); - } - - var lccn = text.trim(); - var table = new $.fn.dataTable.Api( meta.settings ); - var cell = table.cell(meta.row, meta.col); - if (full.status === "success"){ - cell.node().innerHTML = "" + lccn + ""; - $(cell.node()).css('background-color', 'lightgreen'); - } else { - if (new Date(new Date(full.modified).getTime() + 60000) > new Date()){ - $(cell.node()).css('background-color', 'yellow'); - } else { - $(cell.node()).css('background-color', 'lightcoral'); - } - /*$.ajax({ + var lccn = text.trim(); + var table = new $.fn.dataTable.Api(meta.settings); + var cell = table.cell(meta.row, meta.col); + if (full.status === 'success') { + if (full.objid.includes('instances/e')){ + cell.node().innerHTML = '' + lccn + ''; + } else { + cell.node().innerHTML = '' + lccn + ''; + } + + $(cell.node()).css('background-color', 'lightgreen'); + } else { + if (new Date(new Date(full.modified).getTime() + 60000) > new Date()) { + $(cell.node()).css('background-color', 'yellow'); + } else { + $(cell.node()).css('background-color', 'lightcoral'); + } + /* $.ajax({ type: "HEAD", async: true, data: { uri: ldsurl }, @@ -535,839 +549,1018 @@ bfe.define('src/bfe', ['require', 'exports', 'module', 'src/bfestore', 'src/bfel $(cell.node()).css('background-color', 'lightgreen'); }).fail(function(data, text){ if (full.status === "published"){ - $(cell.node()).css('background-color', 'lightcoral'); - } - });*/ - } - } else { - //$(cell.node()).css('background-color', 'lightcoral'); - console.log(full.message); - } - - return text; - } - }, - { - "data": "rdf", - "render": function(data, type, full, meta) { - var text = ""; - if (_.filter(data, function(el) { - return el["http://id.loc.gov/ontologies/bflc/metadataAssigner"] - }).length > 0) - text = _.filter(data, function(el) { - return el["http://id.loc.gov/ontologies/bflc/metadataAssigner"] - })[0]["http://id.loc.gov/ontologies/bflc/metadataAssigner"][0]["@value"]; - return text.length > 60 ? text.substr(0, 58) + "..." : text; - } - }, - { - "data": "modified", - "width": "10%", - "render": function(data, type, row) { - var d = new Date(data); - //Month first - - var hr = d.getHours(); - var min = d.getMinutes(); - var ampm = "a"; - if (min<10) - min = "0"+min; - if (hr>=12){ - ampm = "p"; - } - if (hr > 12){ - hr-=12; - } - return (d.getMonth() + 1) + '-' + d.getDate() + '-' + d.getFullYear() + ' ' + hr + ':' + min + ampm; - } - }, - { - "data": "url", - "width": "10%", - "searchable": false, - "filterable": false, - "sortable": false, - "render": function(td, cellData, rowData, row) { - // return 'edit'; - - return '
    \ + $(cell.node()).css('background-color', 'lightcoral'); + } + }); */ + } + } else { + // $(cell.node()).css('background-color', 'lightcoral'); + // console.log(full.message); + // bfelog.addMsg(new Error(), "INFO", full.message, text); + } + + return text; + } + }, + //comment + { + 'data': 'rdf', + 'render': function (data, type, full, meta) { + var text = ''; + var mahttp = _.findKey(data, 'http://id.loc.gov/ontologies/bflc/metadataAssigner'); + var mahttps = _.findKey(data, 'https://id.loc.gov/ontologies/bflc/metadataAssigner'); + var cihttp = _.findKey(data, 'http://id.loc.gov/ontologies/bflc/catalogerId'); + var cihttps = _.findKey(data, 'https://id.loc.gov/ontologies/bflc/catalogerId'); + if (mahttps) { + text = _.pluck(data[mahttps]['https://id.loc.gov/ontologies/bflc/metadataAssigner'], '@value')[0]; + } else if (mahttp) { + text = _.pluck(data[mahttp]['http://id.loc.gov/ontologies/bflc/metadataAssigner'], '@value')[0]; + } else if (cihttps) { + text = _.pluck(data[cihttps]['https://id.loc.gov/ontologies/bflc/catalogerId'], '@value')[0]; + } else if (cihttp) { + text = _.pluck(data[cihttp]['http://id.loc.gov/ontologies/bflc/catalogerId'], '@value')[0]; + } + // if (_.filter(data, function(el) { + // return el["http://id.loc.gov/ontologies/bflc/metadataAssigner"] + // }).length > 0) + // text = _.filter(data, function(el) { + // return el["http://id.loc.gov/ontologies/bflc/metadataAssigner"] + // })[0]["http://id.loc.gov/ontologies/bflc/metadataAssigner"][0]["@value"]; + return text.length > 60 ? text.substr(0, 58) + '...' : text; + } + }, + //modified + { + 'data': 'modified', + 'width': '10%', + 'render': function (data, type, row) { + var d = new Date(data); + // Month first + + var hr = d.getHours(); + var min = d.getMinutes(); + var ampm = 'a'; + if (min < 10) { min = '0' + min; } + if (hr >= 12) { + ampm = 'p'; + } + if (hr > 12) { + hr -= 12; + } + return (d.getMonth() + 1) + '-' + d.getDate() + '-' + d.getFullYear() + ' ' + hr + ':' + min + ampm; + } + }, + //edit + { + 'data': 'url', + 'width': '10%', + 'searchable': false, + 'filterable': false, + 'sortable': false, + 'render': function (td, cellData, rowData, row) { + // return 'edit'; + + return '
    \ \ -
    ' - }, - "createdCell": function(td, cellData, rowData, row, col) { - - if(rowData.status === "success" || rowData.status === "published") - $(td).find("#bfeditor-delete"+rowData.id).attr("disabled", "disabled"); - - var useguid = guid(); - var loadtemplate = {}; - var tempstore = []; - - bfestore.store = []; - bfestore.loadtemplates = []; - - //default - //var spoints = editorconfig.startingPoints[0].menuItems[0]; - if (rowData.profile !== "profile:bf2:Load:Work" && rowData.profile !== "profile:bf2:IBC:Instance"){ - var menuIndex = _.findIndex(_(editorconfig.startingPoints).chain().find({ - menuItems: [{ - useResourceTemplates: [rowData.profile] - }] - }).value().menuItems, { - useResourceTemplates: [rowData.profile] - }) - var spoints = _(editorconfig.startingPoints).chain().find({ - menuItems: [{ - useResourceTemplates: [rowData.profile] - }] - }).value().menuItems[menuIndex] - } else if (rowData.profile === "profile:bf2:Load:Work"){ - var spoints = { label: "Loaded Work", - type: ["http://id.loc.gov/ontologies/bibframe/Work"], - useResourceTemplates:["profile:bf2:Load:Work"] - }; - } else if (rowData.profile === "profile:bf2:IBC:Instance") { - - var spoints = { label: "IBC", - type: ["http://id.loc.gov/ontologies/bibframe/Instance"], - useResourceTemplates:["profile:bf2:IBC:Instance"] - }; +
    '; + }, + 'createdCell': function (td, cellData, rowData, row, col) { + if (rowData.status === 'success' || rowData.status === 'published') { $(td).find('#bfeditor-delete' + rowData.id).attr('disabled', 'disabled'); } + + var useguid = guid(); + var loadtemplate = {}; + var tempstore = []; + var spoints; + bfestore.store = []; + bfestore.loadtemplates = []; + + // default + // var spoints = editorconfig.startingPoints[0].menuItems[0]; + if (rowData.profile !== 'profile:bf2:Load:Work' && rowData.profile !== 'profile:bf2:IBC:Instance') { + var menuIndex = _.findIndex(_(editorconfig.startingPoints).chain().find({ + menuItems: [{ + useResourceTemplates: [rowData.profile] + }] + }).value().menuItems, { + useResourceTemplates: [rowData.profile] + }); + spoints = _(editorconfig.startingPoints).chain().find({ + menuItems: [{ + useResourceTemplates: [rowData.profile] + }] + }).value().menuItems[menuIndex]; + } else if (rowData.profile === 'profile:bf2:Load:Work') { + spoints = { label: 'Loaded Work', + type: ['http://id.loc.gov/ontologies/bibframe/Work'], + useResourceTemplates: ['profile:bf2:Load:Work'] + }; + } else if (rowData.profile === 'profile:bf2:IBC:Instance') { + spoints = { label: 'IBC', + type: ['http://id.loc.gov/ontologies/bibframe/Instance'], + useResourceTemplates: ['profile:bf2:IBC:Instance'] + }; + } - } + var bTypes = []; + var temptemplates = []; + spoints.useResourceTemplates.forEach(function (l) { + var useguid = guid(); + var loadtemplate = {}; + loadtemplate.templateGUID = rowData.name; + loadtemplate.resourceTemplateID = l; + // loadtemplate.resourceURI = cellData; + // loadtemplate.resourceURI = whichrt(loadtemplate, editorconfig.baseURI) + loadTemplate.templateGUID;//editorconfig.baseURI + useguid; + loadtemplate.embedType = 'page'; + loadtemplate.data = []; + temptemplates.push(loadtemplate); + }); + + $(td).find('#bfeditor-retrieve' + rowData.id).click(function () { + if (editorconfig.retrieve.callback !== undefined) { + // loadtemplates = temptemplates; + bfestore.loadtemplates = temptemplates; + // editorconfig.retrieve.callback(cellData,bfestore, bfelog, cbLoadTemplates); + bfestore.store = []; + bfestore.state = 'edit'; + tempstore = bfestore.jsonld2store(rowData.rdf); + bfestore.name = rowData.name; + bfestore.created = rowData.created; + bfestore.url = rowData.url; + bfestore.profile = rowData.profile; + addedProperties = rowData.addedproperties; + $('[href=#create]').tab('show'); + if ($('#bfeditor-messagediv').length) { + $('#bfeditor-messagediv').remove(); + $('#bfeditor-formdiv').show(); + $('#save-btn').remove(); + $('#bfeditor-previewPanel').remove(); + } + cbLoadTemplates(); + window.location.hash = mintResource(rowData.name); + } else { + // retrieve disabled + addedProperties = []; + } + }); - var bTypes = []; - /*rowData.rdf.forEach(function(t){ - if(t["@type"] !== undefined && t["@type"].length > 0 && t["@id"].indexOf("_:b")){ - //console.log(t["@id"] + " " +t["@type"][0]); - bTypes.push(t["@type"][0]); - } else { - //console.log(); - } - }); - - findRt = _.where(editorconfig.startingPoints, { menuItems:[{type:bTypes}] }) - if (findRt[0] !== undefined){ - spoints = _.where(editorconfig.startingPoints, { menuItems:[{type:bTypes}] })[0].menuItems[0]; - } - */ - var temptemplates = []; - spoints.useResourceTemplates.forEach(function(l) { - var useguid = guid(); - var loadtemplate = {}; - loadtemplate.templateGUID = rowData.name; - loadtemplate.resourceTemplateID = l; - //loadtemplate.resourceURI = cellData; - //loadtemplate.resourceURI = whichrt(loadtemplate, editorconfig.baseURI) + loadTemplate.templateGUID;//editorconfig.baseURI + useguid; - loadtemplate.embedType = "page"; - loadtemplate.data = []; - temptemplates.push(loadtemplate); - }); - - $(td).find("#bfeditor-retrieve" + rowData.id).click(function() { - if (editorconfig.retrieve.callback !== undefined) { - //loadtemplates = temptemplates; - bfestore.loadtemplates = temptemplates; - //editorconfig.retrieve.callback(cellData,bfestore, bfelog, cbLoadTemplates); - bfestore.store = []; - bfestore.state = "edit"; - tempstore = bfestore.jsonld2store(rowData.rdf); - bfestore.name = rowData.name; - bfestore.created = rowData.created; - bfestore.url = rowData.url; - bfestore.profile = rowData.profile; - $('[href=#create]').tab('show'); - if($('#bfeditor-messagediv').length){ - $('#bfeditor-messagediv').remove(); - $('#bfeditor-formdiv').show(); - $('#save-btn').remove(); - $('#bfeditor-previewPanel').remove(); - } - cbLoadTemplates(); - window.location.hash = mintResource(rowData.name); - } else { - //retrieve disabled - } - }); - - $(td).append($('