You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/models/entry.js

119 lines
3.0 KiB

// TODO: This file was created by bulk-decaffeinate.
// Sanity-check the conversion and remove this comment.
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* DS206: Consider reworking classes to avoid initClass
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
//= require app/searcher
(function() {
let applyAliases = undefined;
const Cls = (app.models.Entry = class Entry extends app.Model {
static initClass() {
let ALIASES;
applyAliases = function(string) {
if (ALIASES.hasOwnProperty(string)) {
return [string, ALIASES[string]];
} else {
const words = string.split('.');
for (let i = 0; i < words.length; i++) {
var word = words[i];
if (ALIASES.hasOwnProperty(word)) {
words[i] = ALIASES[word];
return [string, words.join('.')];
}
}
}
return string;
};
this.ALIASES = (ALIASES = {
'angular': 'ng',
'angular.js': 'ng',
'backbone.js': 'bb',
'c++': 'cpp',
'coffeescript': 'cs',
'crystal': 'cr',
'elixir': 'ex',
'javascript': 'js',
'julia': 'jl',
'jquery': '$',
'knockout.js': 'ko',
'kubernetes': 'k8s',
'less': 'ls',
'lodash': '_',
'löve': 'love',
'marionette': 'mn',
'markdown': 'md',
'matplotlib': 'mpl',
'modernizr': 'mdr',
'moment.js': 'mt',
'openjdk': 'java',
'nginx': 'ngx',
'numpy': 'np',
'pandas': 'pd',
'postgresql': 'pg',
'python': 'py',
'ruby.on.rails': 'ror',
'ruby': 'rb',
'rust': 'rs',
'sass': 'scss',
'tensorflow': 'tf',
'typescript': 'ts',
'underscore.js': '_'
});
}
// Attributes: name, type, path
11 years ago
constructor() {
super(...arguments);
this.text = applyAliases(app.Searcher.normalizeString(this.name));
}
addAlias(name) {
const text = applyAliases(app.Searcher.normalizeString(name));
if (!Array.isArray(this.text)) { this.text = [this.text]; }
this.text.push(Array.isArray(text) ? text[1] : text);
}
11 years ago
fullPath() {
return this.doc.fullPath(this.isIndex() ? '' : this.path);
}
11 years ago
dbPath() {
return this.path.replace(/#.*/, '');
}
filePath() {
return this.doc.fullPath(this._filePath());
}
11 years ago
fileUrl() {
return this.doc.fileUrl(this._filePath());
}
11 years ago
_filePath() {
let result = this.path.replace(/#.*/, '');
if (result.slice(-5) !== '.html') { result += '.html'; }
return result;
}
11 years ago
isIndex() {
return this.path === 'index';
}
11 years ago
getType() {
return this.doc.types.findBy('name', this.type);
}
11 years ago
loadFile(onSuccess, onError) {
return app.db.load(this, onSuccess, onError);
}
});
Cls.initClass();
return Cls;
})();