code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
function scroll(e) {
e = e || window.event;
stopBubble(e);
stopDefault(e);
var window_top = $window.scrollTop();
var delta = -e.wheelDelta / 120 || e.detail / 3;
var move = delta * options.steps;
slide(window... | jquery.scrolldiv.js 1.0
http://jquerywidget.com | scroll | javascript | mumuy/widget | code/jquery.scrolldiv.js | https://github.com/mumuy/widget/blob/master/code/jquery.scrolldiv.js | MIT |
function slide(top){
var top = top || $document.scrollTop();
var scroll_height = top - _position_top;
var distance = _maxheight-_window_height;
if (scroll_height < 0) {
$list.css("top", "0px");
} else if(scroll_height>di... | jquery.scrolldiv.js 1.0
http://jquerywidget.com | slide | javascript | mumuy/widget | code/jquery.scrolldiv.js | https://github.com/mumuy/widget/blob/master/code/jquery.scrolldiv.js | MIT |
function stopBubble(e) {
if (e && e.stopPropagation) {
e.stopPropagation();
} else if (window.event) {
window.event.cancelBubble = true;
}
} | jquery.scrolldiv.js 1.0
http://jquerywidget.com | stopBubble | javascript | mumuy/widget | code/jquery.scrolldiv.js | https://github.com/mumuy/widget/blob/master/code/jquery.scrolldiv.js | MIT |
function stopDefault(e) {
if (e && e.preventDefault) {
e.preventDefault();
} else {
window.event.returnValue = false;
}
return false;
} | jquery.scrolldiv.js 1.0
http://jquerywidget.com | stopDefault | javascript | mumuy/widget | code/jquery.scrolldiv.js | https://github.com/mumuy/widget/blob/master/code/jquery.scrolldiv.js | MIT |
down = function(e){
if(isShow){
e.isPropagationStopped();
switch(e.keyCode){
case 13:
_api.setValue($options.eq(_index).val());
isShow = false;
break;
... | jquery.select.js 1.2
http://jquerywidget.com | down | javascript | mumuy/widget | code/jquery.select.js | https://github.com/mumuy/widget/blob/master/code/jquery.select.js | MIT |
function scroll(){
if(!isClose){
var scrolltop = $document.scrollTop();
if(scrolltop<options.scrolltop){
hide();
}else {
show();
}
}
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | scroll | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
function hide(){
if(isShow){
$this.animate({'width':'0px'},options.duration);
isShow = false;
}
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | hide | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
function show(){
if(!isShow){
$this.animate({'width':_width},options.duration);
isShow = true;
}
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | show | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
function close(){
addCookie(options.cookieName,"1",options.expires,options.cookieDomain,options.cookiePath);
hide();
isClose = true;
options.afterClose();
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | close | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
function open(){
// delCookie(options.cookieName,options.cookieDomain,options.cookiePath);
show();
isClose = false;
options.afterOpen();
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | open | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
function delCookie(name,objDomain,objPath){
document.cookie = name+"=;expires="+(new Date(0)).toGMTString()+";domain="+objDomain+";path="+objPath;
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | delCookie | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
function getCookie(objName){
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return unescape(temp[1]);
}
} | jquery.sliderbar.js 1.0
http://jquerywidget.com | getCookie | javascript | mumuy/widget | code/jquery.slidebar.js | https://github.com/mumuy/widget/blob/master/code/jquery.slidebar.js | MIT |
reset = function(){
_height = $this.outerHeight(false);
_width = $this.outerWidth(false);
_top = $this.position().top;
_left = $this.position().left;
$suggestion.css({
'top':_top+_height+'px',
'left':... | jquery.suggestion.js 1.5
http://jquerywidget.com | reset | javascript | mumuy/widget | code/jquery.suggestion.js | https://github.com/mumuy/widget/blob/master/code/jquery.suggestion.js | MIT |
down = function(e){
e.isPropagationStopped();
switch(e.keyCode){
case 13:
_api.hide();
if(_index>=0){
var $target = $items.eq(_index);
var data = {
... | jquery.suggestion.js 1.5
http://jquerywidget.com | down | javascript | mumuy/widget | code/jquery.suggestion.js | https://github.com/mumuy/widget/blob/master/code/jquery.suggestion.js | MIT |
hover = function(e){
e.isPropagationStopped();
var $target = $(this);
_index = $target.index();
$target.addClass(options.activeCls).siblings().removeClass(options.activeCls);
} | jquery.suggestion.js 1.5
http://jquerywidget.com | hover | javascript | mumuy/widget | code/jquery.suggestion.js | https://github.com/mumuy/widget/blob/master/code/jquery.suggestion.js | MIT |
function hasScrolled(element, direction) {
if (direction === 'vertical') {
return element.scrollHeight > element.clientHeight;
} else if (direction === 'horizontal') {
return element.scrollWidth > element.clientWidth;
}
... | jquery.suggestion.js 1.5
http://jquerywidget.com | hasScrolled | javascript | mumuy/widget | code/jquery.suggestion.js | https://github.com/mumuy/widget/blob/master/code/jquery.suggestion.js | MIT |
change = function(){
var $target = $list.find('li.'+options.activeCls);
var data = {
'name':$target.data('name'),
'value':$target.data('value'),
};
var result = options.onChange.bind(_)(data);
if(resu... | jquery.suggestion.js 1.5
http://jquerywidget.com | change | javascript | mumuy/widget | code/jquery.suggestion.js | https://github.com/mumuy/widget/blob/master/code/jquery.suggestion.js | MIT |
reset = function(){
var border_width = parseInt($table.find('th,td').css('border-width')) + parseInt($table.css('border-spacing'))*2;
var thead_height = $table.find('thead').outerHeight(true)+border_width;
var thead_width = border_width;
$table.find('thead... | jquery.tablefixed.js 1.0
http://jquerywidget.com | reset | javascript | mumuy/widget | code/jquery.tablefixed.js | https://github.com/mumuy/widget/blob/master/code/jquery.tablefixed.js | MIT |
getOuterRange = function (range) {
var getRange = function(){
$abledTds.each(function () {
var $temp = $(this);
var t_fromKey = $temp.data('from');
var t_toKey = $temp.data('to');
... | jquery.tableselect.js 1.1
http://jquerywidget.com | getOuterRange | javascript | mumuy/widget | code/jquery.tableselect.js | https://github.com/mumuy/widget/blob/master/code/jquery.tableselect.js | MIT |
getRange = function(){
$abledTds.each(function () {
var $temp = $(this);
var t_fromKey = $temp.data('from');
var t_toKey = $temp.data('to');
var t_from = t_fromKey.split(':').map(funct... | jquery.tableselect.js 1.1
http://jquerywidget.com | getRange | javascript | mumuy/widget | code/jquery.tableselect.js | https://github.com/mumuy/widget/blob/master/code/jquery.tableselect.js | MIT |
sortTableByIndex = function(index,type){
var type = type||'up';
var $bd_tbody = $table.find('tbody');
$bd_tbody.find('td').removeClass(options.activeCls).filter(':nth-child('+(index+1)+')').addClass(options.activeCls);
var $items = $bd_tbody.find('tr');
... | jquery.tablesort.js 1.0
http://jquerywidget.com | sortTableByIndex | javascript | mumuy/widget | code/jquery.tablesort.js | https://github.com/mumuy/widget/blob/master/code/jquery.tablesort.js | MIT |
prev = function(e){
var i = _index?_index-1:_size-1;
var status = {
index: _index,
count: _size,
destination: i,
event:e
};
if(options.onChangeStart(status)!=false){
... | jquery.tabs.js 1.0
http://jquerywidget.com | prev | javascript | mumuy/widget | code/jquery.tabs.js | https://github.com/mumuy/widget/blob/master/code/jquery.tabs.js | MIT |
next = function(e){
var i = (_index + 1)%_size;
var status = {
index: _index,
count: _size,
destination: i,
event:e
};
if(options.onChangeStart(status)!=false){
... | jquery.tabs.js 1.0
http://jquerywidget.com | next | javascript | mumuy/widget | code/jquery.tabs.js | https://github.com/mumuy/widget/blob/master/code/jquery.tabs.js | MIT |
down = function(e){
if(isShow){
e.isPropagationStopped();
switch(e.keyCode){
case 13:
_api.value($options.eq(_index).val());
isShow = false;
break;
... | zepto.select.js 1.0
http://jquerywidget.com | down | javascript | mumuy/widget | code/zepto.select.js | https://github.com/mumuy/widget/blob/master/code/zepto.select.js | MIT |
transformVendorKeys = (manifest, vendor) => {
if (Array.isArray(manifest)) {
return manifest.map(newManifest => {
return transformVendorKeys(newManifest, vendor);
});
}
if (typeof manifest === 'object') {
return Object.entries(manifest).reduce((newManifest, [key, value]) => {
const match ... | Fork of `webextension-toolbox/webpack-webextension-plugin` | transformVendorKeys | javascript | ineo6/git-master | scripts/wext-manifest/transformVendorKeys.js | https://github.com/ineo6/git-master/blob/master/scripts/wext-manifest/transformVendorKeys.js | MIT |
transformVendorKeys = (manifest, vendor) => {
if (Array.isArray(manifest)) {
return manifest.map(newManifest => {
return transformVendorKeys(newManifest, vendor);
});
}
if (typeof manifest === 'object') {
return Object.entries(manifest).reduce((newManifest, [key, value]) => {
const match ... | Fork of `webextension-toolbox/webpack-webextension-plugin` | transformVendorKeys | javascript | ineo6/git-master | scripts/wext-manifest/transformVendorKeys.js | https://github.com/ineo6/git-master/blob/master/scripts/wext-manifest/transformVendorKeys.js | MIT |
async activate(opts, payload) {
return undefined;
} | Activates the plugin.
@param {!{
adapter: !Adapter,
$sidebar: !JQuery,
$toggler: !JQuery,
$views: !JQuery,
treeView: !TreeView,
optsView: !OptionsView,
errorView: !ErrorView,
}}
@param {{
state: UserState,
}}
@return {!Promise<undefined>} | activate | javascript | ineo6/git-master | src/common/core.plugins.js | https://github.com/ineo6/git-master/blob/master/src/common/core.plugins.js | MIT |
async deactivate(payload) {
return undefined;
} | Deactivate the plugin.
@param {{
state: UserState,
}} payload | deactivate | javascript | ineo6/git-master | src/common/core.plugins.js | https://github.com/ineo6/git-master/blob/master/src/common/core.plugins.js | MIT |
async applyOptions(changes) {
return false;
} | Applies the option changes user has made.
@param {!Object<!string, [(string|boolean), (string|boolean)]>} changes
@return {!Promise<boolean>} iff the tree should be reloaded. | applyOptions | javascript | ineo6/git-master | src/common/core.plugins.js | https://github.com/ineo6/git-master/blob/master/src/common/core.plugins.js | MIT |
async function treeTruncate() {
$.jstree.defaults.truncate = $.noop;
$.jstree.plugins.truncate = function(opts, parent) {
this.redraw_node = function(obj, deep, callback, forceDraw) {
obj = parent.redraw_node.call(this, obj, deep, callback, forceDraw);
let anchor = null;
if (obj) {
a... | Mimic logic from JSTree
https://github.com/vakata/jstree/blob/master/src/misc.js#L148
Plugin truncate path name | treeTruncate | javascript | ineo6/git-master | src/common/util.plugins.js | https://github.com/ineo6/git-master/blob/master/src/common/util.plugins.js | MIT |
loadElements() {
this.elements = this.$view.find('[data-store]').toArray();
} | Load elements with [data-store] attributes & attach enforeShowInRule to the
elements in the show in section. Invoke this if there are dynamically added
elements, so that they can be loaded and saved. | loadElements | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
handleTabClick(e) {
const current = $(this);
const index = current.index();
this.setTab(index);
} | Toggles the visibility of this screen. | handleTabClick | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
setTab(index) {
const current = this.$view.find(`.master-tabs-tab:eq(${index})`);
const width = current.outerWidth(true);
current.removeClass('master-tabs-tab-disabled').addClass('master-tabs-tab-active');
const link = this.$view.find('.master-tabs-ink-bar');
const content = this.$view.find('.mast... | Toggles the visibility of this screen. | setTab | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
changeDarkModeWrapper(e) {
this.changeDarkMode(false, e);
} | Toggles the visibility of this screen. | changeDarkModeWrapper | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
changeDarkMode(init, e) {
parallel(
[1],
async (elm, cb) => {
const mode = 'gm-default-theme-' + this.whoami;
let value = await extStore.get(STORE.DARKMODE);
if (!init) {
value = !value;
await extStore.set(STORE.DARKMODE, value);
}
if (valu... | Toggles the visibility of this screen. | changeDarkMode | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
async clearBuildInDarkMode() {
const value = await extStore.get(STORE.DARKMODE);
const mode = 'gm-default-theme-' + this.whoami;
if (value) {
// dark mode off
$('html').removeClass([mode, shareClassName.sidebarDarkCls].join(' '));
await extStore.set(STORE.DARKMODE, !value);
}
//... | Toggles the visibility of this screen. | clearBuildInDarkMode | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
changeDirectionWrapper(e) {
this.changeDirection(false, e);
} | Toggles the visibility of this screen. | changeDirectionWrapper | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
_load() {
this._eachOption(
($elm, key, value, cb) => {
if ($elm.is(':checkbox')) {
$elm.prop('checked', value);
} else if ($elm.is(':radio')) {
$elm.prop('checked', $elm.val() === value);
} else {
$elm.val(value);
}
cb();
},
()... | Toggles the visibility of this screen. | _load | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
_save() {
const changes = {};
this._eachOption(
async ($elm, key, value, cb) => {
if ($elm.is(':radio') && !$elm.is(':checked')) {
return cb();
}
const newValue = $elm.is(':checkbox') ? $elm.is(':checked') : $elm.val();
if (value === newValue) return cb();
... | Toggles the visibility of this screen. | _save | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
_eachOption(processFn, completeFn) {
parallel(
this.elements,
async (elm, cb) => {
const $elm = $(elm);
const key = STORE[$elm.data('store')];
const value = await extStore.get(key);
processFn($elm, key, value, () => cb());
},
completeFn
);
} | Toggles the visibility of this screen. | _eachOption | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
async initDarkModeBtn(init = true) {
// disable when build-in is false
const isBuildInDark = await extStore.get(STORE.BUILD_IN_DARK);
if ([DICT.GITHUB, DICT.GIST].includes(this.whoami) && isBuildInDark) {
!init && unSubscribeDarkMode();
this.$darkMode.show();
} else {
if (!isBuildInD... | Toggles the visibility of this screen. | initDarkModeBtn | javascript | ineo6/git-master | src/common/view.options.js | https://github.com/ineo6/git-master/blob/master/src/common/view.options.js | MIT |
onItemClick(event) {
return false;
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | onItemClick | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
_onItemClick(event) {
let $target = $(event.target);
let download = false;
// Handle middle click
if (event.which === 2) return;
if (this.onItemClick(event)) return;
if ($target.is('i.jstree-icon')) {
$target = $target.parent();
download = true;
} else if (!$target.is('a.jstr... | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | _onItemClick | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
refocusAfterCompletion = () => {
$(document).one('pjax:success page:load', () => {
this.$jstree.get_container().focus();
});
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | refocusAfterCompletion | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
refocusAfterCompletion = () => {
$(document).one('pjax:success page:load', () => {
this.$jstree.get_container().focus();
});
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | refocusAfterCompletion | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
breakPath(fullPath) {
return fullPath.split('/').reduce((res, path, idx) => {
res.push(idx === 0 ? path : `${res[idx - 1]}/${path}`);
return res;
}, []);
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | breakPath | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
parserGitLabRepoPath(path) {
const match = path.match(/(?:[^/]+\/)+blob\/(?:[^/]+\/)(.*)/);
if (match && match.length === 2) {
return match[1];
}
return '';
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | parserGitLabRepoPath | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
parserGiteeRepoPath(path) {
const match = path.match(/(?:[^/]+\/)+branch\/(?:[^/]+\/)(.*)/);
if (match && match.length === 2) {
return match[1];
}
return '';
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | parserGiteeRepoPath | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
parserRepoPath(path) {
const match = path.match(/(?:[^/]+\/){4}(.*)/);
if (match && match.length === 2) {
return match[1];
}
return '';
} | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | parserRepoPath | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
getCurrentFilePath() {
const path = decodeURIComponent(window.location.pathname);
if (this.adapter.whoami() === DICT.GITLAB) {
return this.parserGitLabRepoPath(path);
} else if (this.adapter.whoami() === DICT.GITEA) {
return this.parserGiteeRepoPath(path);
}
return this.parserRepoPath(... | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | getCurrentFilePath | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
async syncSelection(repo) {
const $jstree = this.$jstree;
if (!$jstree) return;
const currentPath = this.getCurrentFilePath();
if (currentPath === '') {
return;
}
const loadAll = await this.adapter.shouldLoadEntireTree(repo);
this.selectPath(loadAll ? [currentPath] : this.breakPath... | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | syncSelection | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
selectPath(paths, index = 0) {
const nodeId = NODE_PREFIX + paths[index];
const $jstree = this.$jstree;
if ($jstree.get_node(nodeId)) {
$jstree.deselect_all();
$jstree.select_node(nodeId);
$jstree.open_node(nodeId, () => {
if (++index < paths.length) {
this.selectPath(p... | Intercept the _onItemClick method
return true to stop the current execution
@param {Event} event | selectPath | javascript | ineo6/git-master | src/common/view.tree.js | https://github.com/ineo6/git-master/blob/master/src/common/view.tree.js | MIT |
_loadCodeTreeInternal(opts, transform, cb) {
const folders = { '': [] };
const { path, repo, node } = opts;
opts.encodedBranch = opts.encodedBranch || encodeURIComponent(decodeURIComponent(repo.branch));
this._getTree(path, opts, (err, tree) => {
if (err) return cb(err);
const treeMap = t... | Loads the code tree of a repository.
@param {Object} opts: {
path: the starting path to load the tree,
repo: the current repository,
node (optional): the selected node (null/false to load entire tree),
token (optional): the personal access token
... | _loadCodeTreeInternal | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
nextChunk = async (iteration = 0) => {
const CHUNK_SIZE = 300;
for (let i = 0; i < CHUNK_SIZE; i++) {
let item = tree[iteration * CHUNK_SIZE + i];
// We're done
if (item === undefined) {
let treeData = folders[''];
treeData = this._so... | Loads the code tree of a repository.
@param {Object} opts: {
path: the starting path to load the tree,
repo: the current repository,
node (optional): the selected node (null/false to load entire tree),
token (optional): the personal access token
... | nextChunk | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
nextChunk = async (iteration = 0) => {
const CHUNK_SIZE = 300;
for (let i = 0; i < CHUNK_SIZE; i++) {
let item = tree[iteration * CHUNK_SIZE + i];
// We're done
if (item === undefined) {
let treeData = folders[''];
treeData = this._so... | Loads the code tree of a repository.
@param {Object} opts: {
path: the starting path to load the tree,
repo: the current repository,
node (optional): the selected node (null/false to load entire tree),
token (optional): the personal access token
... | nextChunk | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
getCssClass() {
throw new Error('Not implemented');
} | Returns the CSS class to be added to sidebar.
@api public | getCssClass | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
getMinWidth() {
return 220;
} | Returns the minimum width acceptable for the sidebar.
@api protected | getMinWidth | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
init($sidebar) {
$sidebar.resizable({
handles: 'e,w',
minWidth: this.getMinWidth(),
});
} | Inits behaviors after the sidebar is added to the DOM.
@api public | init | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
async shouldLoadEntireTree(opts) {
return false;
} | Returns whether we should load the entire tree in a single request.
@api public | shouldLoadEntireTree | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
loadCodeTree(opts, cb) {
throw new Error('Not implemented');
} | Loads the code tree.
@api public | loadCodeTree | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
getCreateTokenUrl() {
throw new Error('Not implemented');
} | Returns the URL to create a personal access token.
@api public | getCreateTokenUrl | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
updateLayout(sidebarPinned, sidebarVisible, sidebarWidth, isSidebarLeft) {
throw new Error('Not implemented');
} | Updates the layout based on sidebar visibility and width.
@api public | updateLayout | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
getRepoFromPath(token, cb) {
throw new Error('Not implemented');
} | Returns repo info at the current path.
@api public | getRepoFromPath | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
selectFile(path) {
if (!isSafari()) {
// Smooth scroll to diff file on PR page
if (path.match(/#diff-\d+$/)) {
const index = Number(path.split('-').slice(-1)[0]);
const matchDom = $('#files .file').eq(index);
if (matchDom.length) {
$('html, body').animate({ scrollTop:... | Selects the file at a specific path.
@api public | selectFile | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
openInNewTab(path) {
window.open(path, '_blank').focus();
} | Opens file or submodule in a new tab.
@api public | openInNewTab | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
buildPatchHtml(treeItem = {}) {
const { action, previous, filesChanged: files, additions, deletions } = treeItem.patch;
let patch = '';
patch += action === 'added' ? '<span class="text-green">added</span>' : '';
patch += action === 'renamed' ? `<span class="text-green" title="${previous}">renamed</span>... | @param {HTML Text} patch
@param {Object} treeItem
Return the patch Html for tree item | buildPatchHtml | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
_getTree(path, opts, cb) {
throw new Error('Not implemented');
} | Gets tree at path.
@param {Object} opts - {token, repo}
@api protected | _getTree | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
_getSubmodules(tree, opts, cb) {
throw new Error('Not implemented');
} | Gets submodules in the tree.
@param {Object} opts - {token, repo, encodedBranch}
@api protected | _getSubmodules | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
getAccessToken() {
throw new Error('Not implemented');
} | Gets submodules in the tree.
@param {Object} opts - {token, repo, encodedBranch}
@api protected | getAccessToken | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
getItemHref(repo, type, encodedPath, encodedBranch) {
return `/${repo.username}/${repo.reponame}/${type}/${encodedBranch}/${encodedPath}`;
} | Returns item's href value.
@api public | getItemHref | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
_getPatchHref(repo, patch) {
return `/${repo.username}/${repo.reponame}/pull/${repo.pullNumber}/files#diff-${patch.diffId}`;
} | Returns patch's href value.
@api protected | _getPatchHref | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
_sort(folder) {
folder.sort((a, b) => {
// eslint-disable-next-line no-nested-ternary
if (a.type === b.type) return a.text === b.text ? 0 : a.text < b.text ? -1 : 1;
return a.type === 'blob' ? 1 : -1;
});
folder.forEach(item => {
if (item.type === 'tree' && item.children !== true &&... | Returns patch's href value.
@api protected | _sort | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
_collapse(folder) {
return folder.map(item => {
if (item.type === 'tree') {
item.children = this._collapse(item.children);
if (item.children.length === 1 && item.children[0].type === 'tree' && item.a_attr) {
const onlyChild = item.children[0];
const path = item.a_attr['data... | Returns patch's href value.
@api protected | _collapse | javascript | ineo6/git-master | src/common/adapters/adapter.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/adapter.js | MIT |
_getPatch(opts, cb) {
const { pullNumber } = opts.repo;
this._get(`/pulls/${pullNumber}/files?per_page=300`, opts, (err, res) => {
if (err) {
cb(err);
} else {
const diffMap = {};
res.forEach((file, index) => {
// Record file patch info
diffMap[file.file... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getPatch | javascript | ineo6/git-master | src/common/adapters/gist.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gist.js | MIT |
async loadRepoData(path, isRepoMetaData = false) {
const token = await this.getAccessToken();
try {
const repo = await this.getRepoDataWrap(false, token);
if (repo) {
const data = await this.getContent(path, {
repo,
isRepoMetaData,
});
return {
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | loadRepoData | javascript | ineo6/git-master | src/common/adapters/gist.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gist.js | MIT |
async getGists(path, opts) {
opts.token = await this.getAccessToken();
return new Promise(resolve => {
this._getTree(path, opts, (err, tree) => {
resolve(tree);
});
});
} | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | getGists | javascript | ineo6/git-master | src/common/adapters/gist.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gist.js | MIT |
_get(path, opts, cb) {
const host = window.location.protocol + '//' + (window.location.host === 'gist.github.com' ? 'api.github.com' : window.location.host + '/api/v3');
let url = `${host}/gists/${opts.repo.gistId}${path ? '/' + path : ''}`;
const cfg = {
url,
method: 'GET',
cache: true,
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _get | javascript | ineo6/git-master | src/common/adapters/gist.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gist.js | MIT |
_getPatch(opts, cb) {
const { pullNumber } = opts.repo;
this._get(`/pulls/${pullNumber}/files?per_page=300`, opts, (err, res) => {
if (err) {
cb(err);
} else {
const diffMap = {};
res.forEach((file, index) => {
// Record file patch info
diffMap[file.file... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getPatch | javascript | ineo6/git-master | src/common/adapters/gitea.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitea.js | MIT |
_getSubmodules(tree, opts, cb) {
const item = tree.filter(item => /^\.gitmodules$/i.test(item.path))[0];
if (!item) return cb();
this._get(`/git/blobs/${item.sha}`, opts, (err, res) => {
if (err) return cb(err);
const data = atob(res.content.replace(/\n/g, ''));
cb(null, parseGitmodules(d... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getSubmodules | javascript | ineo6/git-master | src/common/adapters/gitea.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitea.js | MIT |
async loadRepoData(path, isRepoMetaData = false) {
const token = await this.getAccessToken();
try {
const repo = await this.getRepoDataWrap(false, token);
if (repo) {
const data = await this.getContent(path, {
repo,
isRepoMetaData,
});
return {
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | loadRepoData | javascript | ineo6/git-master | src/common/adapters/gitea.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitea.js | MIT |
getContentPath() {
let str = window.location.href;
let result = str.match(/.*[bt][lr][oe][be]\/[^//]+\/(.*)/); // blob/tree :D
return result && result.length && result[1];
} | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | getContentPath | javascript | ineo6/git-master | src/common/adapters/gitea.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitea.js | MIT |
async getContent(path, opts) {
const host = window.location.protocol + '//' + (window.location.host === 'github.com' ? 'api.github.com' : window.location.host + '/api/v1');
const url = `${host}/repos/${opts.repo.username}/${opts.repo.reponame}`;
const contentPath = path || this.getContentPath() || '';
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | getContent | javascript | ineo6/git-master | src/common/adapters/gitea.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitea.js | MIT |
_get(path, opts, cb) {
let url;
if (path && path.startsWith('http')) {
url = path;
} else {
const host = window.location.protocol + '//' + window.location.host + '/api/v1';
url = `${host}/repos/${opts.repo.username}/${opts.repo.reponame}${path || ''}`;
}
const cfg = {
url,
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _get | javascript | ineo6/git-master | src/common/adapters/gitea.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitea.js | MIT |
async getRepoDataWrap(currentRepo, token) {
if (!githubDetect.shouldEnable()) {
return;
}
return new Promise((resolve, reject) => {
this.getRepoData(currentRepo, token, (error, result) => {
if (!error) {
resolve(result);
}
if (typeof error === 'string') {
... | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | getRepoDataWrap | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
async getRepoFromPath(currentRepo, token, cb) {
if (!githubDetect.shouldEnable()) {
return cb();
}
await this.getRepoData(currentRepo, token, cb);
} | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | getRepoFromPath | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
loadCodeTree(opts, cb) {
opts.encodedBranch = encodeURIComponent(decodeURIComponent(opts.repo.branch));
opts.path = (opts.node && (opts.node.sha || opts.encodedBranch)) || opts.encodedBranch + '?recursive=1';
this._loadCodeTreeInternal(opts, null, cb);
} | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | loadCodeTree | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
getAccessToken() {
return window.extStore.get(window.STORE.GITHUB_TOKEN);
} | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | getAccessToken | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
get isOnPRPage() {
// eslint-disable-next-line no-useless-escape
const match = window.location.pathname.match(/([^\/]+)\/([^\/]+)(?:\/([^\/]+))?(?:\/([^\/]+))?/);
if (!match) return false;
const type = match[3];
return type === 'pull';
} | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | isOnPRPage | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
_getTree(path, opts, cb) {
if (opts.repo.pullNumber) {
this._getPatch(opts, cb);
} else {
this._get(`/git/trees/${path}`, opts, (err, res) => {
if (err) {
cb(err);
} else {
cb(null, res.tree);
}
});
}
} | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | _getTree | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
_getPatch(opts, cb) {
const { pullNumber } = opts.repo;
this._get(`/pulls/${pullNumber}/files?per_page=300`, opts, (err, res) => {
if (err) {
cb(err);
} else {
const diffMap = {};
res.forEach((file, index) => {
// Record file patch info
diffMap[file.file... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getPatch | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
_getSubmodules(tree, opts, cb) {
const item = tree.filter(item => /^\.gitmodules$/i.test(item.path))[0];
if (!item) return cb();
this._get(`/git/blobs/${item.sha}`, opts, (err, res) => {
if (err) return cb(err);
const data = atob(res.content.replace(/\n/g, ''));
cb(null, parseGitmodules(d... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getSubmodules | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
async loadRepoData(path, isRepoMetaData = false) {
const token = await this.getAccessToken();
try {
const repo = await this.getRepoDataWrap(false, token);
if (repo) {
const data = await this.getContent(path, {
repo,
isRepoMetaData,
});
return {
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | loadRepoData | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
getContentPath() {
let str = window.location.href;
let result = str.match(/.*[bt][lr][oe][be]\/[^//]+\/(.*)/); // blob/tree :D
return result && result.length && result[1];
} | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | getContentPath | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
async getContent(path, opts) {
const host = window.location.protocol + '//' + (window.location.host === 'github.com' ? 'api.github.com' : window.location.host + '/api/v3');
const url = `${host}/repos/${opts.repo.username}/${opts.repo.reponame}`;
const contentPath = path || this.getContentPath() || '';
... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | getContent | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
_get(path, opts, cb) {
let url;
if (path && path.startsWith('http')) {
url = path;
} else {
const host = window.location.protocol + '//' + (window.location.host === 'github.com' ? 'api.github.com' : window.location.host + '/api/v3');
url = `${host}/repos/${opts.repo.username}/${opts.repo.... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _get | javascript | ineo6/git-master | src/common/adapters/github.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/github.js | MIT |
_getPatch(opts, cb) {
const { pullNumber } = opts.repo;
this._get(`/pulls/${pullNumber}/files?per_page=300`, opts, (err, res) => {
if (err) {
cb(err);
} else {
const diffMap = {};
res.forEach((file, index) => {
// Record file patch info
diffMap[file.file... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getPatch | javascript | ineo6/git-master | src/common/adapters/gitlab.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitlab.js | MIT |
_getSubmodules(tree, opts, cb) {
// todo gitlab api not support fetch submodule
return cb();
} | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _getSubmodules | javascript | ineo6/git-master | src/common/adapters/gitlab.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitlab.js | MIT |
_get(path, opts, cb) {
const repo = opts.repo;
const version = this.isV3Gitlab() ? 'v3' : 'v4';
const host = `${window.location.protocol}//${window.location.host}/api/${version}`;
const project = $('#search_project_id').val() || $('#project_id').val() || `${repo.username}%2f${repo.reponame}`;
const ... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _get | javascript | ineo6/git-master | src/common/adapters/gitlab.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitlab.js | MIT |
async _handleError(settings, jqXHR, cb) {
let error;
let message;
switch (jqXHR.status) {
case 0:
error = 'Connection error';
message = `Cannot connect to website.
If your network connection to this website is fine, maybe there is an outage of the API.
Please try a... | Get files that were patched in Pull Request.
The diff map that is returned contains changed files, as well as the parents of the changed files.
This allows the tree to be filtered for only folders that contain files with diffs.
@param {Object} opts: {
path: the starting path to load the tree,
... | _handleError | javascript | ineo6/git-master | src/common/adapters/gitlab.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gitlab.js | MIT |
async getRepoDataWrap(currentRepo, token) {
if (!detect.shouldEnable()) {
return;
}
return new Promise((resolve, reject) => {
this.getRepoData(currentRepo, token, (error, result) => {
if (!error) {
resolve(result);
}
if (typeof error === 'string') {
r... | Github renders the branch name in one of below structure depending on the length
of branch name. We're using this for default code page or tree/blob.
Option 1: when the length is short enough
<summary title="Switch branches or tags">
<span class="css-truncate-target">feature/1/2/3</span>
</summary>
Option 2: when t... | getRepoDataWrap | javascript | ineo6/git-master | src/common/adapters/gogs.js | https://github.com/ineo6/git-master/blob/master/src/common/adapters/gogs.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.