diff --git a/models/cloudbrain.go b/models/cloudbrain.go index 4840b78c0..4b4c2c099 100755 --- a/models/cloudbrain.go +++ b/models/cloudbrain.go @@ -1329,6 +1329,9 @@ func QueryModelTrainJobList(repoId int64) ([]*CloudbrainInfo, int, error) { cond = cond.And( builder.Eq{"job_type": "TRAIN"}, ) + cond = cond.And( + builder.In("type", 0, 1), + ) cloudbrains := make([]*CloudbrainInfo, 0) if err := sess.Select("job_id,display_job_name").Table(&Cloudbrain{}).Where(cond).OrderBy("created_unix DESC"). @@ -1795,3 +1798,44 @@ func CloudbrainAll(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { return cloudbrains, count, nil } +func CloudbrainAllStatic(opts *CloudbrainsOptions) ([]*CloudbrainInfo, int64, error) { + sess := x.NewSession() + defer sess.Close() + + var cond = builder.NewCond() + + if (opts.Type) >= 0 { + cond = cond.And( + builder.Eq{"cloudbrain.type": opts.Type}, + ) + } + if opts.BeginTimeUnix > 0 && opts.EndTimeUnix > 0 { + cond = cond.And( + builder.And(builder.Gte{"cloudbrain.created_unix": opts.BeginTimeUnix}, builder.Lte{"cloudbrain.created_unix": opts.EndTimeUnix}), + ) + } + var count int64 + var err error + count, err = sess.Unscoped().Where(cond).Count(new(Cloudbrain)) + + if err != nil { + return nil, 0, fmt.Errorf("Count: %v", err) + } + + if opts.Page >= 0 && opts.PageSize > 0 { + var start int + if opts.Page == 0 { + start = 0 + } else { + start = (opts.Page - 1) * opts.PageSize + } + sess.Limit(opts.PageSize, start) + } + sess.OrderBy("cloudbrain.created_unix DESC") + cloudbrains := make([]*CloudbrainInfo, 0, setting.UI.IssuePagingNum) + if err := sess.Cols("status", "type", "job_type", "train_job_duration", "duration", "compute_resource", "created_unix", "start_time", "end_time").Table(&Cloudbrain{}).Unscoped().Where(cond). + Find(&cloudbrains); err != nil { + return nil, 0, fmt.Errorf("Find: %v", err) + } + return cloudbrains, count, nil +} diff --git a/models/cloudbrain_static.go b/models/cloudbrain_static.go index 27cccf415..03cd7d2bc 100644 --- a/models/cloudbrain_static.go +++ b/models/cloudbrain_static.go @@ -213,7 +213,7 @@ func GetWaittingTop() ([]*CloudbrainInfo, error) { cond = cond.And( builder.Eq{"cloudbrain.status": string(JobWaiting)}, ) - sess.OrderBy("(cloudbrain.start_time-cloudbrain.created_unix) DESC limit 10") + sess.OrderBy("cloudbrain.created_unix ASC limit 10") cloudbrains := make([]*CloudbrainInfo, 0, 10) if err := sess.Table(&Cloudbrain{}).Where(cond). Find(&cloudbrains); err != nil { @@ -228,7 +228,7 @@ func GetRunningTop() ([]*CloudbrainInfo, error) { cond = cond.And( builder.Eq{"cloudbrain.status": string(JobRunning)}, ) - sess.OrderBy("(cloudbrain.end_time-cloudbrain.start_time) DESC limit 10") + sess.OrderBy("cloudbrain.duration DESC limit 10") cloudbrains := make([]*CloudbrainInfo, 0, 10) if err := sess.Table(&Cloudbrain{}).Where(cond). Find(&cloudbrains); err != nil { diff --git a/models/custom_migrations.go b/models/custom_migrations.go old mode 100644 new mode 100755 index 412bedce1..65b53f0f4 --- a/models/custom_migrations.go +++ b/models/custom_migrations.go @@ -15,13 +15,9 @@ type CustomMigrationStatic struct { Migrate func(*xorm.Engine, *xorm.Engine) error } -var customMigrations = []CustomMigration{ - {"Custom v1 Topic struct change to support chinese", syncTopicStruct}, -} +var customMigrations []CustomMigration -var customMigrationsStatic = []CustomMigrationStatic{ - {"update issue_fixed_rate to 1 if num_issues is 0 ", updateIssueFixedRate}, -} +var customMigrationsStatic []CustomMigrationStatic func MigrateCustom(x *xorm.Engine) { diff --git a/models/dataset.go b/models/dataset.go index 2194aa42b..f2f4ef51e 100755 --- a/models/dataset.go +++ b/models/dataset.go @@ -241,12 +241,12 @@ func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond { } } if len(opts.DatasetIDs) > 0 { - if opts.StarByMe { cond = cond.And(builder.In("dataset.id", opts.DatasetIDs)) } else { subCon := builder.NewCond() subCon = subCon.And(builder.In("dataset.id", opts.DatasetIDs)) + subCon = generateFilterCond(opts, subCon) cond = cond.Or(subCon) } } diff --git a/models/user.go b/models/user.go index 7d4c8ce34..dd5a6f1d2 100755 --- a/models/user.go +++ b/models/user.go @@ -6,7 +6,6 @@ package models import ( - "code.gitea.io/gitea/modules/blockchain" "container/list" "context" "crypto/md5" @@ -25,6 +24,8 @@ import ( "time" "unicode/utf8" + "code.gitea.io/gitea/modules/blockchain" + "code.gitea.io/gitea/modules/avatar" "code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/generate" @@ -1498,6 +1499,17 @@ func GetUsersByIDs(ids []int64) (UserList, error) { return ous, err } +func GetUsersByNames(names []string) (UserList, error) { + ous := make([]*User, 0, len(names)) + if len(names) == 0 { + return ous, nil + } + err := x.In("name", names). + Asc("name"). + Find(&ous) + return ous, err +} + // GetUserIDsByNames returns a slice of ids corresponds to names. func GetUserIDsByNames(names []string, ignoreNonExistent bool) ([]int64, error) { ids := make([]int64, 0, len(names)) diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 6c305d296..c6f42ddf5 100755 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1420,7 +1420,7 @@ issues.label_templates.helper=选择标签模板 issues.label_templates.use=使用标签集 issues.label_templates.fail_to_load_file=加载标签模板文件 '%s' 时发生错误:%v issues.add_label_at=添加了标签
%s
%s -issues.remove_label_at=删除了
%s
label %s 标签 +issues.remove_label_at=删除了标签
%s
%s issues.add_milestone_at=` %[2]s 添加了里程碑 %[1]s` issues.change_milestone_at=`%[3]s 修改了里程碑从 %[1]s%[2]s` issues.remove_milestone_at=`%[2]s 删除了里程碑 %[1]s` diff --git a/public/home/home.js b/public/home/home.js index 9754de0cb..f772403f1 100755 --- a/public/home/home.js +++ b/public/home/home.js @@ -74,28 +74,30 @@ var swiperOrg = new Swiper(".homeorg-list", { }, }); -var output = document.getElementById("newmessage"); -var url = "ws://" + document.location.host + "/action/notification"; -if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){ - url = "wss://" + document.location.host + "/action/notification" -} -var socket = new WebSocket(url); - -socket.onopen = function () { - messageQueue = []; - console.log("message has connected."); -}; - var maxSize = 20; var html =document.documentElement; var lang = html.attributes["lang"] var isZh = true; if(lang != null && lang.nodeValue =="en-US" ){ isZh=false; -}else{ } -socket.onmessage = function (e) { +document.onreadystatechange = function () { + queryRecommendData(); + + var output = document.getElementById("newmessage"); + var url = "ws://" + document.location.host + "/action/notification"; + if(document.location.host == "git.openi.org.cn" || document.URL.startsWith("https")){ + url = "wss://" + document.location.host + "/action/notification" + } + var socket = new WebSocket(url); + + socket.onopen = function () { + messageQueue = []; + console.log("message has connected."); + }; + + socket.onmessage = function (e) { var data =JSON.parse(e.data) var html = ""; if (data != null){ @@ -176,7 +178,10 @@ socket.onmessage = function (e) { output.innerHTML = html; swiperNewMessage.updateSlides(); swiperNewMessage.updateProgress(); -}; + }; +} + + function getTaskLink(record){ var re = getRepoLink(record); @@ -217,9 +222,9 @@ function refresh3DInfo(record){ //console.log("cloudbrain two line length=" + lines.length); var span = $('.rotation3D__line').find("span")[1]; //console.log(span); - span.innerText =record.RefName; - //$('.rotation3D__line').find("span").eq(1).text(record.RefName) - //lines[1].find("span").text(record.RefName); + if(span != null){ + span.innerText =record.RefName; + } } } @@ -437,7 +442,9 @@ function getAction(opType,isZh){ } } -queryRecommendData(); + + + function queryRecommendData(){ $.ajax({ @@ -452,48 +459,12 @@ function queryRecommendData(){ displayOrg(json.org); displayRepo(json.repo); displayActivity(json.image); - displayCloudBrain(json.cloudbrain) }, error:function(response) { } }); - - // $.ajax({ - // type:"GET", - // url:"/recommend/repo", - // headers: { - // authorization:token, - // }, - // dataType:"json", - // async:false, - // success:function(json){ - // displayRepo(json); - // }, - // error:function(response) { - // } - // }); - - // $.ajax({ - // type:"GET", - // url:"/recommend/imageinfo", - // headers: { - // authorization:token, - // }, - // dataType:"json", - // async:false, - // success:function(json){ - // displayActivity(json); - // }, - // error:function(response) { - // } - // }); } -function displayCloudBrain(json){ - $('#completed_task').text(json.completed_task); - $('#running_task').text(json.running_task); - $('#wait_task').text(json.wait_task); -} function displayActivity(json){ var activityDiv = document.getElementById("recommendactivity"); diff --git a/public/home/search.js b/public/home/search.js index 2fac95358..f9e815da3 100644 --- a/public/home/search.js +++ b/public/home/search.js @@ -1,1312 +1,1722 @@ var token; -if(isEmpty(token)){ - var meta = $("meta[name=_uid]"); - if(!isEmpty(meta)){ - token = meta.attr("content"); - console.log("token is uid:" + token); - } +if (isEmpty(token)) { + var meta = $("meta[name=_uid]"); + if (!isEmpty(meta)) { + token = meta.attr("content"); + } } -var html =document.documentElement; -var lang = html.attributes["lang"] +var html = document.documentElement; +var lang = html.attributes["lang"]; var isZh = true; -if(lang != null && lang.nodeValue =="en-US" ){ - console.log("the language is " + lang.nodeValue); - isZh=false; -}else{ - console.log("default lang=zh"); +if (lang != null && lang.nodeValue == "en-US") { + isZh = false; +} else { } -function isEmpty(str){ - if(typeof str == "undefined" || str == null || str == ""){ - return true; - } - return false; +function isEmpty(str) { + if (typeof str == "undefined" || str == null || str == "") { + return true; + } + return false; } -var itemType={ - "1":"repository", - "2":"issue", - "3":"user", - "4":"org", - "5":"dataset", - "6":"pr" +var itemType = { + 1: "repository", + 2: "issue", + 3: "user", + 4: "org", + 5: "dataset", + 6: "pr", }; -var sortBy={ - "10":"default", - "11":"updated_unix.keyword", - "12":"num_watches", - "13":"num_stars", - "14":"num_forks", - "20":"default", - "21":"updated_unix.keyword", - "30":"default", - "31":"name.keyword", - "32":"name.keyword", - "33":"created_unix.keyword", - "34":"created_unix.keyword", - "40":"default", - "41":"name.keyword", - "42":"name.keyword", - "43":"created_unix.keyword", - "44":"created_unix.keyword", - "50":"default", - "51":"download_times", - "60":"default", - "61":"updated_unix.keyword" +var sortBy = { + 10: "default", + 11: "updated_unix.keyword", + 12: "num_watches", + 13: "num_stars", + 14: "num_forks", + 20: "default", + 21: "updated_unix.keyword", + 30: "default", + 31: "name.keyword", + 32: "name.keyword", + 33: "created_unix.keyword", + 34: "created_unix.keyword", + 40: "default", + 41: "name.keyword", + 42: "name.keyword", + 43: "created_unix.keyword", + 44: "created_unix.keyword", + 50: "default", + 51: "download_times", + 60: "default", + 61: "updated_unix.keyword", }; -var sortAscending={ - "10":"false", - "11":"false", - "12":"false", - "13":"false", - "14":"false", - "20":"false", - "21":"false", - "30":"false", - "31":"true", - "32":"false", - "33":"false", - "34":"true", - "40":"false", - "41":"true", - "42":"false", - "43":"false", - "44":"true", - "50":"false", - "51":"false", - "60":"false", - "61":"false" +var sortAscending = { + 10: "false", + 11: "false", + 12: "false", + 13: "false", + 14: "false", + 20: "false", + 21: "false", + 30: "false", + 31: "true", + 32: "false", + 33: "false", + 34: "true", + 40: "false", + 41: "true", + 42: "false", + 43: "false", + 44: "true", + 50: "false", + 51: "false", + 60: "false", + 61: "false", }; var currentPage = 1; var pageSize = 15; -var currentSearchTableName ="repository"; -var currentSearchKeyword=""; -var currentSearchSortBy=""; -var currentSearchAscending="false"; -var OnlySearchLabel=false; -var startIndex =1; +var currentSearchTableName = "repository"; +var currentSearchKeyword = ""; +var currentSearchSortBy = ""; +var currentSearchAscending = "false"; +var OnlySearchLabel = false; +var startIndex = 1; var endIndex = 5; var totalPage = 1; var totalNum = 0; var privateTotal = 0; -function initPageInfo(){ - currentPage = 1; - startIndex =1; - endIndex = 5; +function initPageInfo() { + currentPage = 1; + startIndex = 1; + endIndex = 5; } -function searchItem(type,sortType){ - console.log("enter item 2."); - if(OnlySearchLabel){ - doSearchLabel(currentSearchTableName,currentSearchKeyword,sortBy[sortType],sortAscending[sortType]) - }else{ - currentSearchKeyword = document.getElementById("keyword_input").value; - if(!isEmpty(currentSearchKeyword)){ - initPageInfo(); - currentSearchTableName = itemType[type]; - currentSearchSortBy = sortBy[sortType]; - currentSearchAscending = sortAscending[sortType]; - OnlySearchLabel =false; - page(currentPage); - }else{ - emptySearch(); - } - } -} - - - -function search(){ - console.log("enter here 1."); +function searchItem(type, sortType) { + if (OnlySearchLabel) { + doSearchLabel( + currentSearchTableName, + currentSearchKeyword, + sortBy[sortType], + sortAscending[sortType] + ); + } else { currentSearchKeyword = document.getElementById("keyword_input").value; - if(!isEmpty(currentSearchKeyword)){ - currentSearchKeyword = currentSearchKeyword.trim(); - } - if(!isEmpty(currentSearchKeyword)){ - doSpcifySearch(currentSearchTableName,currentSearchKeyword,sortBy[10],"false"); - }else{ - emptySearch(); + if (!isEmpty(currentSearchKeyword)) { + initPageInfo(); + currentSearchTableName = itemType[type]; + currentSearchSortBy = sortBy[sortType]; + currentSearchAscending = sortAscending[sortType]; + OnlySearchLabel = false; + page(currentPage); + } else { + emptySearch(); } + } } -function emptySearch(){ - initDiv(false); - initPageInfo(); - $('#searchForm').addClass("hiddenSearch"); - document.getElementById("find_id").innerHTML=getLabel(isZh,"search_empty"); - $('#find_title').html(""); - document.getElementById("sort_type").innerHTML=""; - document.getElementById("child_search_item").innerHTML=""; - document.getElementById("page_menu").innerHTML=""; - $('#repo_total').text(""); - $('#pr_total').text(""); - $('#issue_total').text(""); - $('#dataset_total').text(""); - $('#user_total').text(""); - $('#org_total').text(""); - setActivate(null); +function search() { + currentSearchKeyword = document.getElementById("keyword_input").value; + if (!isEmpty(currentSearchKeyword)) { + currentSearchKeyword = currentSearchKeyword.trim(); + } + if (!isEmpty(currentSearchKeyword)) { + doSpcifySearch( + currentSearchTableName, + currentSearchKeyword, + sortBy[10], + "false" + ); + } else { + emptySearch(); + } } -function initDiv(isSearchLabel=false){ - if(isSearchLabel){ - document.getElementById("search_div").style.display="none"; - document.getElementById("search_label_div").style.display="block"; - document.getElementById("dataset_item").style.display="none"; - document.getElementById("issue_item").style.display="none"; - document.getElementById("pr_item").style.display="none"; - document.getElementById("user_item").style.display="none"; - document.getElementById("org_item").style.display="none"; - document.getElementById("find_id").innerHTML=""; - }else{ - document.getElementById("search_div").style.display="block"; - document.getElementById("search_label_div").style.display="none"; - document.getElementById("dataset_item").style.display="block"; - document.getElementById("issue_item").style.display="block"; - document.getElementById("pr_item").style.display="block"; - document.getElementById("user_item").style.display="block"; - document.getElementById("org_item").style.display="block"; - document.getElementById("find_id").innerHTML=getLabel(isZh,"search_finded"); - } +function emptySearch() { + initDiv(false); + initPageInfo(); + $("#searchForm").addClass("hiddenSearch"); + document.getElementById("find_id").innerHTML = getLabel(isZh, "search_empty"); + $("#find_title").html(""); + document.getElementById("sort_type").innerHTML = ""; + document.getElementById("child_search_item").innerHTML = ""; + document.getElementById("page_menu").innerHTML = ""; + $("#repo_total").text(""); + $("#pr_total").text(""); + $("#issue_total").text(""); + $("#dataset_total").text(""); + $("#user_total").text(""); + $("#org_total").text(""); + setActivate(null); } -function doSpcifySearch(tableName,keyword,sortBy="",ascending="false"){ - initDiv(false); - $('#searchForm').addClass("hiddenSearch"); - document.getElementById("find_id").innerHTML=getLabel(isZh,"search_finded"); - currentSearchKeyword = keyword; - initPageInfo(); - currentSearchTableName = tableName; - currentSearchSortBy = sortBy; - currentSearchAscending = ascending; - OnlySearchLabel =false; - - page(currentPage); - - if(currentSearchTableName != "repository"){ - doSearch("repository",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "issue"){ - doSearch("issue",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "user"){ - doSearch("user",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "org"){ - doSearch("org",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "dataset"){ - doSearch("dataset",currentSearchKeyword,1,pageSize,true,"",false); - } - if(currentSearchTableName != "pr"){ - doSearch("pr",currentSearchKeyword,1,pageSize,true,"",false); - } +function initDiv(isSearchLabel = false) { + if (isSearchLabel) { + document.getElementById("search_div").style.display = "none"; + document.getElementById("search_label_div").style.display = "block"; + document.getElementById("dataset_item").style.display = "none"; + document.getElementById("issue_item").style.display = "none"; + document.getElementById("pr_item").style.display = "none"; + document.getElementById("user_item").style.display = "none"; + document.getElementById("org_item").style.display = "none"; + document.getElementById("find_id").innerHTML = ""; + } else { + document.getElementById("search_div").style.display = "block"; + document.getElementById("search_label_div").style.display = "none"; + document.getElementById("dataset_item").style.display = "block"; + document.getElementById("issue_item").style.display = "block"; + document.getElementById("pr_item").style.display = "block"; + document.getElementById("user_item").style.display = "block"; + document.getElementById("org_item").style.display = "block"; + document.getElementById("find_id").innerHTML = getLabel( + isZh, + "search_finded" + ); + } } -function doSearchLabel(tableName,keyword,sortBy="",ascending="false"){ - initDiv(true); - //document.getElementById("search_div").style.display="none"; - //document.getElementById("search_label_div").style.display="block"; - document.getElementById("search_label_div").innerHTML="

#" + keyword + "

"; - - currentSearchKeyword = keyword; - initPageInfo(); - currentSearchTableName = tableName; - currentSearchSortBy = sortBy; - currentSearchAscending = ascending; - OnlySearchLabel =true; - - page(currentPage); +function doSpcifySearch(tableName, keyword, sortBy = "", ascending = "false") { + initDiv(false); + $("#searchForm").addClass("hiddenSearch"); + document.getElementById("find_id").innerHTML = getLabel( + isZh, + "search_finded" + ); + currentSearchKeyword = keyword; + initPageInfo(); + currentSearchTableName = tableName; + currentSearchSortBy = sortBy; + currentSearchAscending = ascending; + OnlySearchLabel = false; + + page(currentPage); + + if (currentSearchTableName != "repository") { + doSearch("repository", currentSearchKeyword, 1, pageSize, true, "", false); + } + if (currentSearchTableName != "issue") { + doSearch("issue", currentSearchKeyword, 1, pageSize, true, "", false); + } + if (currentSearchTableName != "user") { + doSearch("user", currentSearchKeyword, 1, pageSize, true, "", false); + } + if (currentSearchTableName != "org") { + doSearch("org", currentSearchKeyword, 1, pageSize, true, "", false); + } + if (currentSearchTableName != "dataset") { + doSearch("dataset", currentSearchKeyword, 1, pageSize, true, "", false); + } + if (currentSearchTableName != "pr") { + doSearch("pr", currentSearchKeyword, 1, pageSize, true, "", false); + } } -function searchLabel(tableName,keyword,sortBy="",ascending="false"){ +function doSearchLabel(tableName, keyword, sortBy = "", ascending = "false") { + initDiv(true); + //document.getElementById("search_div").style.display="none"; + //document.getElementById("search_label_div").style.display="block"; + document.getElementById("search_label_div").innerHTML = + '

#' + keyword + "

"; + + currentSearchKeyword = keyword; + initPageInfo(); + currentSearchTableName = tableName; + currentSearchSortBy = sortBy; + currentSearchAscending = ascending; + OnlySearchLabel = true; + + page(currentPage); +} - sessionStorage.setItem("keyword",keyword); - sessionStorage.setItem("tableName",tableName); - sessionStorage.setItem("searchLabel",true); - sessionStorage.setItem("sortBy",sortBy); - sessionStorage.setItem("ascending",ascending); - console.log("enter label search."); - window.open("/all/search/"); +function searchLabel(tableName, keyword, sortBy = "", ascending = "false") { + sessionStorage.setItem("keyword", keyword); + sessionStorage.setItem("tableName", tableName); + sessionStorage.setItem("searchLabel", true); + sessionStorage.setItem("sortBy", sortBy); + sessionStorage.setItem("ascending", ascending); + window.open("/all/search/"); } -function doSearch(tableName,keyword,page,pageSize=15,onlyReturnNum=true,sortBy="",OnlySearchLabel=false){ - var language = "zh-CN"; - if(!isZh){ - language="en-US"; - } - $.ajax({ - type:"GET", - url:"/all/dosearch/", - headers: { - authorization:token, - }, - dataType:"json", - data:{ - 'TableName': tableName, - 'Key': keyword, - 'Page': page, - 'PageSize': pageSize, - 'OnlyReturnNum':onlyReturnNum, - 'SortBy':sortBy, - 'OnlySearchLabel':OnlySearchLabel, - 'Ascending':currentSearchAscending, - 'WebTotal':totalNum, - 'PrivateTotal':privateTotal, - 'language':language - }, - async:true, - success:function(json){ - console.log("tableName=" + tableName); - console.log(json); - displayResult(tableName,page,json,onlyReturnNum,keyword); - }, - error:function(response) { - console.log(response); - } - }); +function doSearch( + tableName, + keyword, + page, + pageSize = 15, + onlyReturnNum = true, + sortBy = "", + OnlySearchLabel = false +) { + var language = "zh-CN"; + if (!isZh) { + language = "en-US"; + } + $.ajax({ + type: "GET", + url: "/all/dosearch/", + headers: { + authorization: token, + }, + dataType: "json", + data: { + TableName: tableName, + Key: keyword, + Page: page, + PageSize: pageSize, + OnlyReturnNum: onlyReturnNum, + SortBy: sortBy, + OnlySearchLabel: OnlySearchLabel, + Ascending: currentSearchAscending, + WebTotal: totalNum, + PrivateTotal: privateTotal, + language: language, + }, + async: true, + success: function (json) { + displayResult(tableName, page, json, onlyReturnNum, keyword); + }, + error: function (response) {}, + }); } -function displayResult(tableName,page,jsonResult,onlyReturnNum,keyword){ - if(tableName == "repository") { - displayRepoResult(page,jsonResult,onlyReturnNum,keyword); - } else if (tableName == "issue") { - displayIssueResult(page,jsonResult,onlyReturnNum,keyword); - } else if (tableName == "user") { - displayUserResult(page,jsonResult,onlyReturnNum,keyword); - } else if (tableName == "org") { - displayOrgResult(page,jsonResult,onlyReturnNum,keyword); - } else if (tableName == "dataset") { - displayDataSetResult(page,jsonResult,onlyReturnNum,keyword); - } else if (tableName == "pr") { - displayPrResult(page,jsonResult,onlyReturnNum,keyword); - } - if(!onlyReturnNum){ - console.log("set total num." + tableName); - totalPage =Math.ceil(jsonResult.Total/pageSize); - totalNum = jsonResult.Total; - privateTotal = jsonResult.PrivateTotal; - setPage(page); - } - +function displayResult(tableName, page, jsonResult, onlyReturnNum, keyword) { + if (tableName == "repository") { + displayRepoResult(page, jsonResult, onlyReturnNum, keyword); + } else if (tableName == "issue") { + displayIssueResult(page, jsonResult, onlyReturnNum, keyword); + } else if (tableName == "user") { + displayUserResult(page, jsonResult, onlyReturnNum, keyword); + } else if (tableName == "org") { + displayOrgResult(page, jsonResult, onlyReturnNum, keyword); + } else if (tableName == "dataset") { + displayDataSetResult(page, jsonResult, onlyReturnNum, keyword); + } else if (tableName == "pr") { + displayPrResult(page, jsonResult, onlyReturnNum, keyword); + } + if (!onlyReturnNum) { + totalPage = Math.ceil(jsonResult.Total / pageSize); + totalNum = jsonResult.Total; + privateTotal = jsonResult.PrivateTotal; + setPage(page); + } } -function displayPrResult(page,jsonResult,onlyReturnNum,keyword){ - var data = jsonResult.Result; - var total = jsonResult.Total; - $('#pr_total').text(total); - if(!onlyReturnNum){ - setActivate("pr_item"); - //$('#keyword_desc').text(keyword); - //$('#obj_desc').text(getLabel(isZh,"search_pr")); - //$('#child_total').text(total); - $('#find_title').html(getLabel(isZh,"find_title").replace('{keyword}',keyword).replace('{tablename}',getLabel(isZh,"search_pr")).replace('{total}',total)); - - setIssueOrPrInnerHtml(data,"pulls"); - } +function displayPrResult(page, jsonResult, onlyReturnNum, keyword) { + var data = jsonResult.Result; + var total = jsonResult.Total; + $("#pr_total").text(total); + if (!onlyReturnNum) { + setActivate("pr_item"); + //$('#keyword_desc').text(keyword); + //$('#obj_desc').text(getLabel(isZh,"search_pr")); + //$('#child_total').text(total); + $("#find_title").html( + getLabel(isZh, "find_title") + .replace("{keyword}", keyword) + .replace("{tablename}", getLabel(isZh, "search_pr")) + .replace("{total}", total) + ); + + setIssueOrPrInnerHtml(data, "pulls"); + } } -var categoryDesc={ - "computer_vision":"计算机视觉", - "natural_language_processing":"自然语言处理", - "speech_processing":"语音处理", - "computer_vision_natural_language_processing":"计算机视觉、自然语言处理" +var categoryDesc = { + computer_vision: "计算机视觉", + natural_language_processing: "自然语言处理", + speech_processing: "语音处理", + computer_vision_natural_language_processing: "计算机视觉、自然语言处理", }; -var categoryENDesc={ - "computer_vision":"computer vision", - "natural_language_processing":"natural language processing", - "speech_processing":"speech processing", - "computer_vision_natural_language_processing":"computer vision and natural language processing" +var categoryENDesc = { + computer_vision: "computer vision", + natural_language_processing: "natural language processing", + speech_processing: "speech processing", + computer_vision_natural_language_processing: + "computer vision and natural language processing", }; -var taskDesc={ - "machine_translation":"机器翻译", - "question_answering_system":"问答系统", - "information_retrieval":"信息检索", - "knowledge_graph":"知识图谱", - "text_annotation":"文本标注", - "text_categorization":"文本分类", - "emotion_analysis":"情感分析", - "language_modeling":"语言建模", - "speech_recognition":"语音识别", - "automatic_digest":"自动文摘", - "information_extraction":"信息抽取", - "description_generation":"说明生成", - "image_classification":"图像分类", - "face_recognition":"人脸识别", - "image_search":"图像搜索", - "target_detection":"目标检测", - "image_description_generation":"图像描述生成", - "vehicle_license_plate_recognition":"车辆车牌识别", - "medical_image_analysis":"医学图像分析", - "unmanned":"无人驾驶", - "unmanned_security":"无人安防", - "drone":"无人机", - "vr_ar":"VR/AR", - "2_d_vision":"2-D视觉", - "2_5_d_vision":"2.5-D视觉", - "3_d_reconstruction":"3D重构", - "image_processing":"图像处理", - "video_processing":"视频处理", - "visual_input_system":"视觉输入系统", - "speech_coding":"语音编码", - "speech_enhancement":"语音增强", - "speech_recognition":"语音识别", - "speech_synthesis":"语音合成" +var taskDesc = { + machine_translation: "机器翻译", + question_answering_system: "问答系统", + information_retrieval: "信息检索", + knowledge_graph: "知识图谱", + text_annotation: "文本标注", + text_categorization: "文本分类", + emotion_analysis: "情感分析", + language_modeling: "语言建模", + speech_recognition: "语音识别", + automatic_digest: "自动文摘", + information_extraction: "信息抽取", + description_generation: "说明生成", + image_classification: "图像分类", + face_recognition: "人脸识别", + image_search: "图像搜索", + target_detection: "目标检测", + image_description_generation: "图像描述生成", + vehicle_license_plate_recognition: "车辆车牌识别", + medical_image_analysis: "医学图像分析", + unmanned: "无人驾驶", + unmanned_security: "无人安防", + drone: "无人机", + vr_ar: "VR/AR", + "2_d_vision": "2-D视觉", + "2_5_d_vision": "2.5-D视觉", + "3_d_reconstruction": "3D重构", + image_processing: "图像处理", + video_processing: "视频处理", + visual_input_system: "视觉输入系统", + speech_coding: "语音编码", + speech_enhancement: "语音增强", + speech_recognition: "语音识别", + speech_synthesis: "语音合成", }; -var taskENDesc={ - "machine_translation":"machine translation", - "question_answering_system":"question answering system", - "information_retrieval":"information retrieval", - "knowledge_graph":"knowledge graph", - "text_annotation":"text annotation", - "text_categorization":"text categorization", - "emotion_analysis":"emotion analysis", - "language_modeling":"language modeling", - "speech_recognition":"speech recognition", - "automatic_digest":"automatic digest", - "information_extraction":"information extraction", - "description_generation":"description generation", - "image_classification":"image classification", - "face_recognition":"face recognition", - "image_search":"image search", - "target_detection":"target detection", - "image_description_generation":"image description generation", - "vehicle_license_plate_recognition":"vehicle license plate recognition", - "medical_image_analysis":"medical image analysis", - "unmanned":"unmanned", - "unmanned_security":"unmanned security", - "drone":"drone", - "vr_ar":"VR/AR", - "2_d_vision":"2.D vision", - "2.5_d_vision":"2.5D vision", - "3_d_reconstruction":"3Dreconstruction", - "image_processing":"image processing", - "video_processing":"video processing", - "visual_input_system":"visual input system", - "speech_coding":"speech coding", - "speech_enhancement":"speech enhancement", - "speech_recognition":"speech recognition", - "speech_synthesis":"speech synthesis" +var taskENDesc = { + machine_translation: "machine translation", + question_answering_system: "question answering system", + information_retrieval: "information retrieval", + knowledge_graph: "knowledge graph", + text_annotation: "text annotation", + text_categorization: "text categorization", + emotion_analysis: "emotion analysis", + language_modeling: "language modeling", + speech_recognition: "speech recognition", + automatic_digest: "automatic digest", + information_extraction: "information extraction", + description_generation: "description generation", + image_classification: "image classification", + face_recognition: "face recognition", + image_search: "image search", + target_detection: "target detection", + image_description_generation: "image description generation", + vehicle_license_plate_recognition: "vehicle license plate recognition", + medical_image_analysis: "medical image analysis", + unmanned: "unmanned", + unmanned_security: "unmanned security", + drone: "drone", + vr_ar: "VR/AR", + "2_d_vision": "2.D vision", + "2.5_d_vision": "2.5D vision", + "3_d_reconstruction": "3Dreconstruction", + image_processing: "image processing", + video_processing: "video processing", + visual_input_system: "visual input system", + speech_coding: "speech coding", + speech_enhancement: "speech enhancement", + speech_recognition: "speech recognition", + speech_synthesis: "speech synthesis", }; -function getCategoryDesc(isZh,key){ - var re = key; - if(isZh){ - re = categoryDesc[key]; - }else{ - re = categoryENDesc[key]; - } - if(isEmpty(re)){ - return key; - } - return re; +function getCategoryDesc(isZh, key) { + var re = key; + if (isZh) { + re = categoryDesc[key]; + } else { + re = categoryENDesc[key]; + } + if (isEmpty(re)) { + return key; + } + return re; } -function getTaskDesc(isZh,key){ - var re = key; - if(isZh){ - re = taskDesc[key]; - }else{ - re = taskENDesc[key]; - } - if(isEmpty(re)){ - return key; - } - return re; +function getTaskDesc(isZh, key) { + var re = key; + if (isZh) { + re = taskDesc[key]; + } else { + re = taskENDesc[key]; + } + if (isEmpty(re)) { + return key; + } + return re; } -function getActiveItem(sort_type){ - console.log("currentSearchSortBy=" + currentSearchSortBy + " sort_type=" + sortBy[sort_type]); - if(currentSearchSortBy == sortBy[sort_type] && currentSearchAscending == sortAscending[sort_type]){ - return "active "; - }else{ - return ""; - } +function getActiveItem(sort_type) { + if ( + currentSearchSortBy == sortBy[sort_type] && + currentSearchAscending == sortAscending[sort_type] + ) { + return "active "; + } else { + return ""; + } } -function displayDataSetResult(page,jsonResult,onlyReturnNum,keyword){ - var data = jsonResult.Result; - var total = jsonResult.Total; - $('#dataset_total').text(total); - if(!onlyReturnNum){ - setActivate("dataset_item"); - //$('#keyword_desc').text(keyword); - //$('#obj_desc').text(getLabel(isZh,"search_dataset")); - //$('#child_total').text(total); - $('#find_title').html(getLabel(isZh,"find_title").replace('{keyword}',keyword).replace('{tablename}',getLabel(isZh,"search_dataset")).replace('{total}',total)); - - var sortHtml = ""; - sortHtml +=""+ getLabel(isZh,"search_matched") + ""; - sortHtml +=""+ getLabel(isZh,"search_matched_download") + ""; - document.getElementById("sort_type").innerHTML=sortHtml; - - var html = ""; - var currentTime = new Date().getTime(); - for(var i = 0; i < data.length;i++){ - var recordMap = data[i]; - html += "
"; - html += "
"; - html += "
" ; - if(!isEmpty(recordMap["category"])){ - html += " " + getCategoryDesc(isZh,recordMap["category"]) + ""; - } - if(!isEmpty(recordMap["task"])){ - html += " " + getTaskDesc(isZh,recordMap["task"]) + ""; - } - html += " " +recordMap["download_times"] + " "; - html +="
"; - html += "
"; - html += " " + recordMap["title"] + ""; - html +=" "; - html +="
"; - html += "
"; - html += "

" + recordMap["description"] + "

"; - if(!isEmpty(recordMap["file_name"])){ - html += "

" + recordMap["file_name"] + "

"; - } - html +="

"; - html +=" "+ getLabel(isZh,"search_lasted_update") + " " + recordMap["updated_html"]; - html +="

"; - html +="
"; - html +="
"; - html +="
"; - } - document.getElementById("child_search_item").innerHTML=html; - } -} +function displayDataSetResult(page, jsonResult, onlyReturnNum, keyword) { + var data = jsonResult.Result; + var total = jsonResult.Total; + $("#dataset_total").text(total); + if (!onlyReturnNum) { + setActivate("dataset_item"); + //$('#keyword_desc').text(keyword); + //$('#obj_desc').text(getLabel(isZh,"search_dataset")); + //$('#child_total').text(total); + $("#find_title").html( + getLabel(isZh, "find_title") + .replace("{keyword}", keyword) + .replace("{tablename}", getLabel(isZh, "search_dataset")) + .replace("{total}", total) + ); -function displayOrgResult(page,jsonResult,onlyReturnNum,keyword){ - var data = jsonResult.Result; - var total = jsonResult.Total; - $('#org_total').text(total); - if(!onlyReturnNum){ - setActivate("org_item"); - //$('#keyword_desc').text(keyword); - //$('#obj_desc').text(getLabel(isZh,"search_org")); - //$('#child_total').text(total); - $('#find_title').html(getLabel(isZh,"find_title").replace('{keyword}',keyword).replace('{tablename}',getLabel(isZh,"search_org")).replace('{total}',total)); - - var sortHtml = ""; - sortHtml +=""+ getLabel(isZh,"search_matched") + ""; - sortHtml +=""+ getLabel(isZh,"search_letter_asc") + ""; - sortHtml +=""+ getLabel(isZh,"search_letter_desc") + ""; - sortHtml +=""+ getLabel(isZh,"search_lasted_create") + ""; - sortHtml +=""+ getLabel(isZh,"search_early_create") + ""; - document.getElementById("sort_type").innerHTML=sortHtml; - - var html = ""; - var currentTime = new Date().getTime(); - for(var i = 0; i < data.length;i++){ - var recordMap = data[i]; - html += "
"; - html += ""; - html += "
"; - html += " "; - html += "
"; - html += "

" + recordMap["description"] + "

"; - html +="

"; - if(!isEmpty(recordMap["location"]) && recordMap["location"] != "null"){ - html +=" " + recordMap["location"]; - } - html +=" "; - if(!isEmpty(recordMap["website"]) && recordMap["website"] != "null"){ - html +=" " + "" + recordMap["website"] + ""; - } - html +=" "+ getLabel(isZh,"search_add_by") + " "; - html += recordMap["add_time"] - html +="

"; - html +="
"; - html +="
"; - html +="
"; - } - document.getElementById("child_search_item").innerHTML=html; - } -} -var monthDisplay=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Spt","Oct","Nov","Dec"); -function displayUserResult(page,jsonResult,onlyReturnNum,keyword){ - var data = jsonResult.Result; - var total = jsonResult.Total; - $('#user_total').text(total); - if(!onlyReturnNum){ - setActivate("user_item"); - //$('#keyword_desc').text(keyword); - //$('#obj_desc').text(getLabel(isZh,"search_user")); - //$('#child_total').text(total); - - $('#find_title').html(getLabel(isZh,"find_title").replace('{keyword}',keyword).replace('{tablename}',getLabel(isZh,"search_user")).replace('{total}',total)); - - var sortHtml = "";//equal user sort by - sortHtml +=""+ getLabel(isZh,"search_matched") + ""; - sortHtml +=""+ getLabel(isZh,"search_letter_asc") + ""; - sortHtml +=""+ getLabel(isZh,"search_letter_desc") + ""; - sortHtml +=""+ getLabel(isZh,"search_lasted_create") + ""; - sortHtml +=""+ getLabel(isZh,"search_early_create") + ""; - - document.getElementById("sort_type").innerHTML=sortHtml; - - var html = ""; - var currentTime = new Date().getTime(); - for(var i = 0; i < data.length;i++){ - var recordMap = data[i]; - html += "
"; - html += ""; - html += "
"; - html += " "; - html += "
"; - html += "

" + recordMap["description"] + "

"; - html +="

"; - if(!isEmpty(recordMap["email"]) && recordMap["email"] != "null"){ - html +="  " + recordMap["email"] + ""; - } - html +=" "+ getLabel(isZh,"search_add_by") + " "; - html += recordMap["add_time"] - html +="

"; - html +="
"; - html +="
"; - html +="
"; - } - document.getElementById("child_search_item").innerHTML=html; + var sortHtml = ""; + sortHtml += + '' + + getLabel(isZh, "search_matched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_matched_download") + + ""; + document.getElementById("sort_type").innerHTML = sortHtml; + + var html = ""; + var currentTime = new Date().getTime(); + for (var i = 0; i < data.length; i++) { + var recordMap = data[i]; + html += '
'; + html += '
'; + html += '
'; + if (!isEmpty(recordMap["category"])) { + html += + ' ' + + getCategoryDesc(isZh, recordMap["category"]) + + ""; + } + if (!isEmpty(recordMap["task"])) { + html += + ' ' + + getTaskDesc(isZh, recordMap["task"]) + + ""; + } + html += + ' ' + + recordMap["download_times"] + + " "; + html += "
"; + html += '
'; + html += + ' ' + + recordMap["title"] + + ""; + html += + ' '; + html += "
"; + html += '
'; + html += + '

' + recordMap["description"] + "

"; + if (!isEmpty(recordMap["file_name"])) { + html += + '

' + recordMap["file_name"] + "

"; + } + html += '

'; + html += + ' ' + + getLabel(isZh, "search_lasted_update") + + " " + + recordMap["updated_html"]; + html += "

"; + html += "
"; + html += "
"; + html += "
"; } + document.getElementById("child_search_item").innerHTML = html; + } } -function setIssueOrPrInnerHtml(data,path){ +function displayOrgResult(page, jsonResult, onlyReturnNum, keyword) { + var data = jsonResult.Result; + var total = jsonResult.Total; + $("#org_total").text(total); + if (!onlyReturnNum) { + setActivate("org_item"); + //$('#keyword_desc').text(keyword); + //$('#obj_desc').text(getLabel(isZh,"search_org")); + //$('#child_total').text(total); + $("#find_title").html( + getLabel(isZh, "find_title") + .replace("{keyword}", keyword) + .replace("{tablename}", getLabel(isZh, "search_org")) + .replace("{total}", total) + ); + var sortHtml = ""; - if(path =="issues"){ - sortHtml +=""+ getLabel(isZh,"search_matched") + ""; - sortHtml +=""+ getLabel(isZh,"search_lasted") + ""; - }else{ - sortHtml +=""+ getLabel(isZh,"search_matched") + ""; - sortHtml +=""+ getLabel(isZh,"search_lasted") + ""; - } - - document.getElementById("sort_type").innerHTML=sortHtml; + sortHtml += + '' + + getLabel(isZh, "search_matched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_letter_asc") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_letter_desc") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_lasted_create") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_early_create") + + ""; + document.getElementById("sort_type").innerHTML = sortHtml; var html = ""; var currentTime = new Date().getTime(); - for(var i = 0; i < data.length;i++){ - var recordMap = data[i]; - html += "
"; - html += "
"; - html += "
"; - html += " " + recordMap["name"] + ""; - html +="
"; - html += "
"; - html += "

" + recordMap["content"] + "

"; - html +="

"; - html +=" "; - html +=" " + addBlank(recordMap["repoUrl"]) +" #" + recordMap["index"] + "    "; - html +="  "; - if(recordMap["is_closed"] != null && (!(recordMap["is_closed"]) || recordMap["is_closed"]=="f")){ - html += getLabel(isZh,"search_open"); - }else{ - html += getLabel(isZh,"search_closed"); - } - html +="      " + recordMap["num_comments"]; - - html +="     "+ getLabel(isZh,"search_lasted_update") + " "+ recordMap["updated_html"]; - - html +="

"; - html +="
"; - html +="
"; - html +="
"; + for (var i = 0; i < data.length; i++) { + var recordMap = data[i]; + html += '
'; + html += + ''; + html += '
'; + html += ' "; + html += '
'; + html += + '

' + recordMap["description"] + "

"; + html += '

'; + if (!isEmpty(recordMap["location"]) && recordMap["location"] != "null") { + html += + ' ' + + recordMap["location"]; + } + html += ' '; + if (!isEmpty(recordMap["website"]) && recordMap["website"] != "null") { + html += + ' ' + + '' + + recordMap["website"] + + ""; + } + html += + ' ' + + getLabel(isZh, "search_add_by") + + " "; + html += recordMap["add_time"]; + html += "

"; + html += "
"; + html += "
"; + html += "
"; } - document.getElementById("child_search_item").innerHTML=html; + document.getElementById("child_search_item").innerHTML = html; + } } +var monthDisplay = new Array( + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Spt", + "Oct", + "Nov", + "Dec" +); +function displayUserResult(page, jsonResult, onlyReturnNum, keyword) { + var data = jsonResult.Result; + var total = jsonResult.Total; + $("#user_total").text(total); + if (!onlyReturnNum) { + setActivate("user_item"); + //$('#keyword_desc').text(keyword); + //$('#obj_desc').text(getLabel(isZh,"search_user")); + //$('#child_total').text(total); + + $("#find_title").html( + getLabel(isZh, "find_title") + .replace("{keyword}", keyword) + .replace("{tablename}", getLabel(isZh, "search_user")) + .replace("{total}", total) + ); + + var sortHtml = ""; //equal user sort by + sortHtml += + '' + + getLabel(isZh, "search_matched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_letter_asc") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_letter_desc") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_lasted_create") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_early_create") + + ""; + + document.getElementById("sort_type").innerHTML = sortHtml; -function addBlank(url){ - if(url == null){ - return url; - } - var tmps = url.split("/"); - if(tmps.length == 2){ - return tmps[0] + " / " + tmps[1]; - } - return url; + var html = ""; + var currentTime = new Date().getTime(); + for (var i = 0; i < data.length; i++) { + var recordMap = data[i]; + html += '
'; + html += + ''; + html += '
'; + html += ' "; + html += '
'; + html += + '

' + recordMap["description"] + "

"; + html += '

'; + if (!isEmpty(recordMap["email"]) && recordMap["email"] != "null") { + html += + '  ' + + recordMap["email"] + + ""; + } + html += + ' ' + + getLabel(isZh, "search_add_by") + + " "; + html += recordMap["add_time"]; + html += "

"; + html += "
"; + html += "
"; + html += "
"; + } + document.getElementById("child_search_item").innerHTML = html; + } } -function displayIssueResult(page,jsonResult,onlyReturnNum,keyword){ - var data = jsonResult.Result; - var total = jsonResult.Total; - $('#issue_total').text(total); - if(!onlyReturnNum){ - setActivate("issue_item"); - //$('#keyword_desc').text(keyword); - //$('#obj_desc').text(getLabel(isZh,"search_issue")); - //$('#child_total').text(total); - $('#find_title').html(getLabel(isZh,"find_title").replace('{keyword}',keyword).replace('{tablename}',getLabel(isZh,"search_issue")).replace('{total}',total)); - - setIssueOrPrInnerHtml(data,"issues"); +function setIssueOrPrInnerHtml(data, path) { + var sortHtml = ""; + if (path == "issues") { + sortHtml += + '' + + getLabel(isZh, "search_matched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_lasted") + + ""; + } else { + sortHtml += + '' + + getLabel(isZh, "search_matched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_lasted") + + ""; + } + + document.getElementById("sort_type").innerHTML = sortHtml; + + var html = ""; + var currentTime = new Date().getTime(); + for (var i = 0; i < data.length; i++) { + var recordMap = data[i]; + html += '
'; + html += '
'; + html += '
'; + html += + ' ' + + recordMap["name"] + + ""; + html += "
"; + html += '
'; + html += '

' + recordMap["content"] + "

"; + html += '

'; + html += ' '; + html += + ' ' + + addBlank(recordMap["repoUrl"]) + + " #" + + recordMap["index"] + + "    "; + html += '  '; + if ( + recordMap["is_closed"] != null && + (!recordMap["is_closed"] || recordMap["is_closed"] == "f") + ) { + html += getLabel(isZh, "search_open"); + } else { + html += getLabel(isZh, "search_closed"); } + html += + '      ' + + recordMap["num_comments"]; + + html += + '     ' + + getLabel(isZh, "search_lasted_update") + + " " + + recordMap["updated_html"]; + + html += "

"; + html += "
"; + html += "
"; + html += "
"; + } + document.getElementById("child_search_item").innerHTML = html; } -function setActivate(name){ - $('#repo_item').removeClass("active"); - $('#user_item').removeClass("active"); - $('#issue_item').removeClass("active"); - $('#dataset_item').removeClass("active"); - $('#org_item').removeClass("active"); - $('#pr_item').removeClass("active"); - if(name==null){ - return; - } - var tmp = "#" + name; - $(tmp).addClass("active"); +function addBlank(url) { + if (url == null) { + return url; + } + var tmps = url.split("/"); + if (tmps.length == 2) { + return tmps[0] + " / " + tmps[1]; + } + return url; } -function displayRepoResult(page,jsonResult,onlyReturnNum,keyword){ - var data = jsonResult.Result; - var total = jsonResult.Total; - $('#repo_total').text(total); - - if(!onlyReturnNum){ - setActivate("repo_item"); - // $('#keyword_desc').text(keyword); - //$('#obj_desc').text(getLabel(isZh,"search_repo")); - //$('#child_total').text(total); - $('#find_title').html(getLabel(isZh,"find_title").replace('{keyword}',keyword).replace('{tablename}',getLabel(isZh,"search_repo")).replace('{total}',total)); - - var sortHtml = ""; - sortHtml +=""+ getLabel(isZh,"search_matched") + ""; - sortHtml +=""+ getLabel(isZh,"search_lasted") + ""; - sortHtml +=""+ getLabel(isZh,"search_watched") + ""; - sortHtml +=""+ getLabel(isZh,"search_star") + ""; - sortHtml +=""+ getLabel(isZh,"search_fork") + ""; - - document.getElementById("sort_type").innerHTML=sortHtml; - - var html = ""; - var currentTime = new Date().getTime(); - for(var i = 0; i < data.length;i++){ - var recordMap = data[i]; - html += "
"; - if(!isEmpty(recordMap['avatar'])){ - html += ""; - } - html += "
"; - html += "
"; - html += " " + recordMap["owner_name"] +" / " + recordMap["alias"] + ""; - if(recordMap["is_private"]){ - html +=" "; - } - html +="
"; - html += "
"; - html += "

" + recordMap["description"] + "

"; - html += "
"; - if(!isEmpty(recordMap["topics"]) && recordMap["topics"] !="null"){ - for(var j = 0; j < recordMap["topics"].length;j++){ - //function searchLabel(tableName,keyword,sortBy="",ascending=false) - html +="
"+ recordMap["hightTopics"][j] + "
"; - } - } - html +="
"; - html +="

"; - html +="  " + recordMap["num_watches"] + "   " + recordMap["num_stars"] + "   " + recordMap["num_forks"] +"  "; - html +="    "+ getLabel(isZh,"search_lasted_update") + " " + recordMap["updated_html"]; - if(!isEmpty(recordMap["lang"])){ - var lang = recordMap["lang"] - var tmpLang = recordMap["lang"].split(","); - if(tmpLang.length>0){ - lang = tmpLang[0] - } - var backColor = "#3572A5"; - if(LanguagesColor[lang] != null){ - backColor = LanguagesColor[lang]; - } - html +="  " + lang + ""; - } - html +="

"; - html +="
"; - html +="
"; - html +="
"; - } +function displayIssueResult(page, jsonResult, onlyReturnNum, keyword) { + var data = jsonResult.Result; + var total = jsonResult.Total; + $("#issue_total").text(total); + if (!onlyReturnNum) { + setActivate("issue_item"); + //$('#keyword_desc').text(keyword); + //$('#obj_desc').text(getLabel(isZh,"search_issue")); + //$('#child_total').text(total); + $("#find_title").html( + getLabel(isZh, "find_title") + .replace("{keyword}", keyword) + .replace("{tablename}", getLabel(isZh, "search_issue")) + .replace("{total}", total) + ); + + setIssueOrPrInnerHtml(data, "issues"); + } +} - document.getElementById("child_search_item").innerHTML=html; - } +function setActivate(name) { + $("#repo_item").removeClass("active"); + $("#user_item").removeClass("active"); + $("#issue_item").removeClass("active"); + $("#dataset_item").removeClass("active"); + $("#org_item").removeClass("active"); + $("#pr_item").removeClass("active"); + if (name == null) { + return; + } + var tmp = "#" + name; + $(tmp).addClass("active"); } -function getTime(UpdatedUnix,currentTime){ - UpdatedUnix = UpdatedUnix; - currentTime = currentTime / 1000; - var timeEscSecond = currentTime - UpdatedUnix; - if( timeEscSecond < 0){ - timeEscSecond = 1; +function LetterAvatar(name, size, color) { + name = name || ""; + size = size || 60; + var colours = [ + "#1abc9c", + "#2ecc71", + "#3498db", + "#9b59b6", + "#34495e", + "#16a085", + "#27ae60", + "#2980b9", + "#8e44ad", + "#2c3e50", + "#f1c40f", + "#e67e22", + "#e74c3c", + "#00bcd4", + "#95a5a6", + "#f39c12", + "#d35400", + "#c0392b", + "#bdc3c7", + "#7f8c8d", + ], + nameSplit = String(name).split(" "), + initials, + charIndex, + colourIndex, + canvas, + context, + dataURI; + if (nameSplit.length == 1) { + initials = nameSplit[0] ? nameSplit[0].charAt(0) : "?"; + } else { + initials = nameSplit[0].charAt(0) + nameSplit[1].charAt(0); + } + if (w.devicePixelRatio) { + size = size * w.devicePixelRatio; + } + + charIndex = (initials == "?" ? 72 : initials.charCodeAt(0)) - 64; + colourIndex = charIndex % 20; + canvas = d.createElement("canvas"); + canvas.width = size; + canvas.height = size; + context = canvas.getContext("2d"); + + context.fillStyle = color ? color : colours[colourIndex - 1]; + context.fillRect(0, 0, canvas.width, canvas.height); + context.font = Math.round(canvas.width / 2) + "px 'Microsoft Yahei'"; + context.textAlign = "center"; + context.fillStyle = "#FFF"; + context.fillText(initials, size / 2, size / 1.5); + dataURI = canvas.toDataURL(); + canvas = null; + return dataURI; +} +LetterAvatar.transform = function () { + Array.prototype.forEach.call( + d.querySelectorAll("img[avatar]"), + function (img, name, color) { + name = img.getAttribute("avatar"); + color = img.getAttribute("color"); + img.src = LetterAvatar(name, img.getAttribute("width"), color); + img.removeAttribute("avatar"); + img.setAttribute("alt", name); } - console.log("currentTime=" + currentTime + " updateUnix=" + UpdatedUnix); - - var hours= Math.floor(timeEscSecond / 3600); - //计算相差分钟数 - var leave2 = Math.floor(timeEscSecond % (3600)); //计算小时数后剩余的秒数 - var minutes= Math.floor(leave2 / 60);//计算相差分钟数 - - var leave3=Math.floor(leave2 % 60); //计算分钟数后剩余的秒数 - var seconds= leave3; - - if(hours == 0 && minutes == 0){ - return seconds + getRepoOrOrg(6,isZh); - }else{ - if(hours > 0){ - if(hours >= 24){ - var days = Math.ceil(hours/24) - if (days >= 30 && days <365){ - return Math.ceil(days/30) + getRepoOrOrg(8,isZh); - }else if(days >= 365){ - return Math.ceil(days/365) + getRepoOrOrg(9,isZh); - } - return Math.ceil(hours/24) + getRepoOrOrg(7,isZh); - }else{ - return hours + getRepoOrOrg(4,isZh); - } - }else{ - return minutes + getRepoOrOrg(5,isZh); + ); +}; + +function displayRepoResult(page, jsonResult, onlyReturnNum, keyword) { + var data = jsonResult.Result; + var total = jsonResult.Total; + $("#repo_total").text(total); + + if (!onlyReturnNum) { + setActivate("repo_item"); + // $('#keyword_desc').text(keyword); + //$('#obj_desc').text(getLabel(isZh,"search_repo")); + //$('#child_total').text(total); + $("#find_title").html( + getLabel(isZh, "find_title") + .replace("{keyword}", keyword) + .replace("{tablename}", getLabel(isZh, "search_repo")) + .replace("{total}", total) + ); + + var sortHtml = ""; + sortHtml += + '' + + getLabel(isZh, "search_matched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_lasted") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_watched") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_star") + + ""; + sortHtml += + '' + + getLabel(isZh, "search_fork") + + ""; + + document.getElementById("sort_type").innerHTML = sortHtml; + + var html = ""; + var currentTime = new Date().getTime(); + for (var i = 0; i < data.length; i++) { + var recordMap = data[i]; + html += '
'; + if (recordMap["avatar"]) { + html += ``; + } else { + html += ``; + } + + html += '
'; + html += '
'; + html += + ' ' + + recordMap["owner_name"] + + " / " + + recordMap["alias"] + + ""; + if (recordMap["is_private"]) { + html += + ' '; + } + html += "
"; + html += '
'; + html += + '

' + recordMap["description"] + "

"; + html += '
'; + if (!isEmpty(recordMap["topics"]) && recordMap["topics"] != "null") { + for (var j = 0; j < recordMap["topics"].length; j++) { + //function searchLabel(tableName,keyword,sortBy="",ascending=false) + html += + "
" + + recordMap["hightTopics"][j] + + "
"; + } + } + html += "
"; + html += '

'; + html += + '  ' + + recordMap["num_watches"] + + '   ' + + recordMap["num_stars"] + + '   ' + + recordMap["num_forks"] + + "  "; + html += + "    " + + getLabel(isZh, "search_lasted_update") + + " " + + recordMap["updated_html"]; + if (!isEmpty(recordMap["lang"])) { + var lang = recordMap["lang"]; + var tmpLang = recordMap["lang"].split(","); + if (tmpLang.length > 0) { + lang = tmpLang[0]; + } + var backColor = "#3572A5"; + if (LanguagesColor[lang] != null) { + backColor = LanguagesColor[lang]; } + html += + '  ' + + lang + + ""; + } + html += "

"; + html += "
"; + html += "
"; + html += "
"; } + + document.getElementById("child_search_item").innerHTML = html; + LetterAvatar.transform(); + } } -function getRepoOrOrg(key,isZhLang){ - if(isZhLang){ - return repoAndOrgZH[key]; - }else{ - return repoAndOrgEN[key]; +function getTime(UpdatedUnix, currentTime) { + UpdatedUnix = UpdatedUnix; + currentTime = currentTime / 1000; + var timeEscSecond = currentTime - UpdatedUnix; + if (timeEscSecond < 0) { + timeEscSecond = 1; + } + + var hours = Math.floor(timeEscSecond / 3600); + //计算相差分钟数 + var leave2 = Math.floor(timeEscSecond % 3600); //计算小时数后剩余的秒数 + var minutes = Math.floor(leave2 / 60); //计算相差分钟数 + + var leave3 = Math.floor(leave2 % 60); //计算分钟数后剩余的秒数 + var seconds = leave3; + + if (hours == 0 && minutes == 0) { + return seconds + getRepoOrOrg(6, isZh); + } else { + if (hours > 0) { + if (hours >= 24) { + var days = Math.ceil(hours / 24); + if (days >= 30 && days < 365) { + return Math.ceil(days / 30) + getRepoOrOrg(8, isZh); + } else if (days >= 365) { + return Math.ceil(days / 365) + getRepoOrOrg(9, isZh); + } + return Math.ceil(hours / 24) + getRepoOrOrg(7, isZh); + } else { + return hours + getRepoOrOrg(4, isZh); + } + } else { + return minutes + getRepoOrOrg(5, isZh); } + } } -var repoAndOrgZH={ - "1":"项目", - "2":"成员", - "3":"团队", - "4":"小时前", - "5":"分钟前", - "6":"秒前", - "7":"天前", - "8":"个月前", - "9":"年前" -}; +function getRepoOrOrg(key, isZhLang) { + if (isZhLang) { + return repoAndOrgZH[key]; + } else { + return repoAndOrgEN[key]; + } +} -var repoAndOrgEN={ - "1":"repository", - "2":"Members ", - "3":"Teams", - "4":" hours ago", - "5":" minutes ago", - "6":" seconds ago", - "7":" day ago", - "8":" month ago", - "9":" year ago" +var repoAndOrgZH = { + 1: "项目", + 2: "成员", + 3: "团队", + 4: "小时前", + 5: "分钟前", + 6: "秒前", + 7: "天前", + 8: "个月前", + 9: "年前", }; +var repoAndOrgEN = { + 1: "repository", + 2: "Members ", + 3: "Teams", + 4: " hours ago", + 5: " minutes ago", + 6: " seconds ago", + 7: " day ago", + 8: " month ago", + 9: " year ago", +}; +function page(current) { + currentPage = current; + + doSearch( + currentSearchTableName, + currentSearchKeyword, + current, + pageSize, + false, + currentSearchSortBy, + OnlySearchLabel + ); +} +function nextPage() { + currentPage = currentPage + 1; + page(currentPage); +} -function page(current){ - - currentPage=current; - - doSearch(currentSearchTableName,currentSearchKeyword,current,pageSize,false,currentSearchSortBy,OnlySearchLabel); - } - - function nextPage(){ - currentPage = currentPage+1; - console.log("currentPage=" + currentPage); - +function prePage() { + if (currentPage > 1) { + currentPage = currentPage - 1; page(currentPage); } - - function prePage(){ - console.log("currentPage=" + currentPage); - if(currentPage > 1){ - currentPage = currentPage-1; - console.log("currentPage=" + (currentPage)); - page(currentPage); - } - } +} -function getXPosition(e){ - var x=e.offsetLeft; - while(e=e.offsetParent) - { - x+=e.offsetLeft; - } - return x+20;//-260防止屏幕超出 +function getXPosition(e) { + var x = e.offsetLeft; + while ((e = e.offsetParent)) { + x += e.offsetLeft; + } + return x + 20; //-260防止屏幕超出 } //获取y坐标 -function getYPosition(e){ - var y=e.offsetTop; - while(e=e.offsetParent) - { - y+=e.offsetTop; - } - return y+20;//80为input高度 +function getYPosition(e) { + var y = e.offsetTop; + while ((e = e.offsetParent)) { + y += e.offsetTop; + } + return y + 20; //80为input高度 } +function goPage(event) { + var inputpage = document.getElementById("inputpage_div"); + var left = getXPosition(event.target); + var top = getYPosition(event.target); + var goNum = $("#inputpage").val(); + if (goNum <= 0) { + showTip(getLabel(isZh, "search_input_large_0"), "warning", left + 5, top); + } else if (goNum <= totalPage) { + page(parseInt(goNum, 10)); + } else { + showTip(getLabel(isZh, "search_input_maxed"), "warning", left + 5, top); + } +} - function goPage(event){ - - var inputpage = document.getElementById("inputpage_div") - var left = getXPosition(event.target); - var top = getYPosition(event.target); - var goNum = $('#inputpage').val(); - if (goNum<=0){ - showTip(getLabel(isZh,"search_input_large_0"),"warning",left+5,top); - } - else if(goNum<=totalPage){ - page(parseInt(goNum,10)); - } - else{ - showTip(getLabel(isZh,"search_input_maxed"),"warning",left+5,top); - } +function showTip(tip, type, left, top) { + var $tip = $("#tipmsg"); + var tipmsg = document.getElementById("tipmsg"); + var style = + "z-index:10024;top:" + + top + + "px;left:" + + left + + "px;position:absolute;width:200px;height:60px;vertical-align:middle;"; + tipmsg.style = style; + var html = "

" + tip + "

"; + $tip + .stop(true) + .prop("class", "alert alert-" + type) + .html(html) + .fadeIn(500) + .delay(2000) + .fadeOut(500); +} + +function setPage(currentPage) { + var html = ""; + startIndex = currentPage - 1; + if (startIndex < 1) { + startIndex = 1; + } + endIndex = currentPage + 2; + if (endIndex >= totalPage) { + endIndex = totalPage; + } + html += + '' + + getLabel(isZh, "search_input_total") + + " " + + totalNum + + " " + + getLabel(isZh, "search_srtip") + + ""; + if (currentPage > 1) { + html += + '' + + getLabel(isZh, "search_home_page") + + ""; + html += + ''; + } else { + html += + '' + + getLabel(isZh, "search_home_page") + + ""; + html += + ''; } - function showTip(tip, type,left,top) { - var $tip = $('#tipmsg'); - var tipmsg = document.getElementById("tipmsg") - var style="z-index:10024;top:" + top + "px;left:" + left + "px;position:absolute;width:200px;height:60px;vertical-align:middle;"; - console.log(style); - tipmsg.style = style; - var html ="

" + tip + "

" - $tip.stop(true).prop('class', 'alert alert-' + type).html(html).fadeIn(500).delay(2000).fadeOut(500); - } - - function setPage(currentPage){ - console.log("totalPage=" + totalPage); - var html =""; - console.log("currentPage=" + currentPage); - console.log("privateTotal=" + privateTotal); - startIndex = currentPage -1; - if(startIndex < 1){ - startIndex = 1; - } - endIndex = currentPage + 2; - if(endIndex >= totalPage){ - endIndex = totalPage; + for (var i = startIndex; i <= endIndex; i++) { + var page_i = i; + if (page_i > totalPage) { + break; } - html += "" + getLabel(isZh,"search_input_total") + " " + totalNum + " " + getLabel(isZh,"search_srtip") + "" - if(currentPage > 1){ - html += "" + getLabel(isZh,"search_home_page") + ""; - html += ""; - }else{ - html += "" + getLabel(isZh,"search_home_page") + ""; - html += ""; - } - - for(var i=startIndex; i <= endIndex; i++){ - var page_i = i; - if(page_i > totalPage){ - break; - } - if( page_i == currentPage){ - html += "" + page_i + ""; - }else{ - html += "" + page_i + ""; - } - } - - if (endIndex < totalPage-1){ - html += "..."; - html += "" + totalPage + ""; + if (page_i == currentPage) { + html += + '' + + page_i + + ""; + } else { + html += + '' + + page_i + + ""; } + } - if(currentPage >=totalPage){ - html += ""; - html += "" + getLabel(isZh,"search_last_page") + ""; - }else{ - html += ""; - html += "" + getLabel(isZh,"search_last_page") + ""; - } + if (endIndex < totalPage - 1) { + html += "..."; + html += + '' + + totalPage + + ""; + } - html +="
" + getLabel(isZh,"search_go_to") + "
" + getLabel(isZh,"search_go_page") + "
"; - console.log("html=" + html) - document.getElementById("page_menu").innerHTML=html; - $('#inputpage').on('keypress',function(event){ - if(event.keyCode == 13){ - goPage(event); - } - }); + if (currentPage >= totalPage) { + html += + ''; + html += + '' + + getLabel(isZh, "search_last_page") + + ""; + } else { + html += + ''; + html += + '' + + getLabel(isZh, "search_last_page") + + ""; } -$('#keyword_input').on('keypress',function(event){ - if(event.keyCode == 13){ - search(); + html += + '
' + + getLabel(isZh, "search_go_to") + + '
' + + getLabel(isZh, "search_go_page") + + "
"; + document.getElementById("page_menu").innerHTML = html; + $("#inputpage").on("keypress", function (event) { + if (event.keyCode == 13) { + goPage(event); } -}); - - - + }); +} +$("#keyword_input").on("keypress", function (event) { + if (event.keyCode == 13) { + search(); + } +}); var LanguagesColor = { - "1C Enterprise": "#814CCC", - "ABAP": "#E8274B", - "AGS Script": "#B9D9FF", - "AMPL": "#E6EFBB", - "ANTLR": "#9DC3FF", - "API Blueprint": "#2ACCA8", - "APL": "#5A8164", - "ASP": "#6a40fd", - "ATS": "#1ac620", - "ActionScript": "#882B0F", - "Ada": "#02f88c", - "Agda": "#315665", - "Alloy": "#64C800", - "AngelScript": "#C7D7DC", - "AppleScript": "#101F1F", - "Arc": "#aa2afe", - "AspectJ": "#a957b0", - "Assembly": "#6E4C13", - "Asymptote": "#4a0c0c", - "AutoHotkey": "#6594b9", - "AutoIt": "#1C3552", - "Ballerina": "#FF5000", - "Batchfile": "#C1F12E", - "BlitzMax": "#cd6400", - "Boo": "#d4bec1", - "Brainfuck": "#2F2530", - "C": "#555555", - "C#": "#178600", - "C++": "#f34b7d", - "CSS": "#563d7c", - "Ceylon": "#dfa535", - "Chapel": "#8dc63f", - "Cirru": "#ccccff", - "Clarion": "#db901e", - "Clean": "#3F85AF", - "Click": "#E4E6F3", - "Clojure": "#db5855", - "CoffeeScript": "#244776", - "ColdFusion": "#ed2cd6", - "Common Lisp": "#3fb68b", - "Common Workflow Language": "#B5314C", - "Component Pascal": "#B0CE4E", - "Crystal": "#000100", - "Cuda": "#3A4E3A", - "D": "#ba595e", - "DM": "#447265", - "Dart": "#00B4AB", - "DataWeave": "#003a52", - "Dhall": "#dfafff", - "Dockerfile": "#384d54", - "Dogescript": "#cca760", - "Dylan": "#6c616e", - "E": "#ccce35", - "ECL": "#8a1267", - "EQ": "#a78649", - "Eiffel": "#946d57", - "Elixir": "#6e4a7e", - "Elm": "#60B5CC", - "Emacs Lisp": "#c065db", - "EmberScript": "#FFF4F3", - "Erlang": "#B83998", - "F#": "#b845fc", - "F*": "#572e30", - "FLUX": "#88ccff", - "Factor": "#636746", - "Fancy": "#7b9db4", - "Fantom": "#14253c", - "Faust": "#c37240", - "Forth": "#341708", - "Fortran": "#4d41b1", - "FreeMarker": "#0050b2", - "Frege": "#00cafe", - "G-code": "#D08CF2", - "GAML": "#FFC766", - "GDScript": "#355570", - "Game Maker Language": "#71b417", - "Genie": "#fb855d", - "Gherkin": "#5B2063", - "Glyph": "#c1ac7f", - "Gnuplot": "#f0a9f0", - "Go": "#00ADD8", - "Golo": "#88562A", - "Gosu": "#82937f", - "Grammatical Framework": "#79aa7a", - "Groovy": "#e69f56", - "HTML": "#e34c26", - "Hack": "#878787", - "Harbour": "#0e60e3", - "Haskell": "#5e5086", - "Haxe": "#df7900", - "HiveQL": "#dce200", - "HolyC": "#ffefaf", - "Hy": "#7790B2", - "IDL": "#a3522f", - "IGOR Pro": "#0000cc", - "Idris": "#b30000", - "Io": "#a9188d", - "Ioke": "#078193", - "Isabelle": "#FEFE00", - "J": "#9EEDFF", - "JSONiq": "#40d47e", - "Java": "#b07219", - "JavaScript": "#f1e05a", - "Jolie": "#843179", - "Jsonnet": "#0064bd", - "Julia": "#a270ba", - "Jupyter Notebook": "#DA5B0B", - "KRL": "#28430A", - "Kotlin": "#F18E33", - "LFE": "#4C3023", - "LLVM": "#185619", - "LOLCODE": "#cc9900", - "LSL": "#3d9970", - "Lasso": "#999999", - "Lex": "#DBCA00", - "LiveScript": "#499886", - "LookML": "#652B81", - "Lua": "#000080", - "MATLAB": "#e16737", - "MAXScript": "#00a6a6", - "MLIR": "#5EC8DB", - "MQL4": "#62A8D6", - "MQL5": "#4A76B8", - "MTML": "#b7e1f4", - "Makefile": "#427819", - "Mask": "#f97732", - "Max": "#c4a79c", - "Mercury": "#ff2b2b", - "Meson": "#007800", - "Metal": "#8f14e9", - "Mirah": "#c7a938", - "Modula-3": "#223388", - "NCL": "#28431f", - "Nearley": "#990000", - "Nemerle": "#3d3c6e", - "NetLinx": "#0aa0ff", - "NetLinx+ERB": "#747faa", - "NetLogo": "#ff6375", - "NewLisp": "#87AED7", - "Nextflow": "#3ac486", - "Nim": "#37775b", - "Nit": "#009917", - "Nix": "#7e7eff", - "Nu": "#c9df40", - "OCaml": "#3be133", - "ObjectScript": "#424893", - "Objective-C": "#438eff", - "Objective-C++": "#6866fb", - "Objective-J": "#ff0c5a", - "Odin": "#60AFFE", - "Omgrofl": "#cabbff", - "Opal": "#f7ede0", - "OpenQASM": "#AA70FF", - "Oxygene": "#cdd0e3", - "Oz": "#fab738", - "P4": "#7055b5", - "PHP": "#4F5D95", - "PLSQL": "#dad8d8", - "Pan": "#cc0000", - "Papyrus": "#6600cc", - "Parrot": "#f3ca0a", - "Pascal": "#E3F171", - "Pawn": "#dbb284", - "Pep8": "#C76F5B", - "Perl": "#0298c3", - "PigLatin": "#fcd7de", - "Pike": "#005390", - "PogoScript": "#d80074", - "PostScript": "#da291c", - "PowerBuilder": "#8f0f8d", - "PowerShell": "#012456", - "Processing": "#0096D8", - "Prolog": "#74283c", - "Propeller Spin": "#7fa2a7", - "Puppet": "#302B6D", - "PureBasic": "#5a6986", - "PureScript": "#1D222D", - "Python": "#3572A5", - "QML": "#44a51c", - "Quake": "#882233", - "R": "#198CE7", - "RAML": "#77d9fb", - "RUNOFF": "#665a4e", - "Racket": "#3c5caa", - "Ragel": "#9d5200", - "Raku": "#0000fb", - "Rascal": "#fffaa0", - "Reason": "#ff5847", - "Rebol": "#358a5b", - "Red": "#f50000", - "Ren'Py": "#ff7f7f", - "Ring": "#2D54CB", - "Riot": "#A71E49", - "Roff": "#ecdebe", - "Rouge": "#cc0088", - "Ruby": "#701516", - "Rust": "#dea584", - "SAS": "#B34936", - "SQF": "#3F3F3F", - "SRecode Template": "#348a34", - "SaltStack": "#646464", - "Scala": "#c22d40", - "Scheme": "#1e4aec", - "Self": "#0579aa", - "Shell": "#89e051", - "Shen": "#120F14", - "Slash": "#007eff", - "Slice": "#003fa2", - "SmPL": "#c94949", - "Smalltalk": "#596706", - "Solidity": "#AA6746", - "SourcePawn": "#5c7611", - "Squirrel": "#800000", - "Stan": "#b2011d", - "Standard ML": "#dc566d", - "Starlark": "#76d275", - "SuperCollider": "#46390b", - "Swift": "#ffac45", - "SystemVerilog": "#DAE1C2", - "TI Program": "#A0AA87", - "Tcl": "#e4cc98", - "TeX": "#3D6117", - "Terra": "#00004c", - "Turing": "#cf142b", - "TypeScript": "#2b7489", - "UnrealScript": "#a54c4d", - "V": "#5d87bd", - "VBA": "#867db1", - "VBScript": "#15dcdc", - "VCL": "#148AA8", - "VHDL": "#adb2cb", - "Vala": "#fbe5cd", - "Verilog": "#b2b7f8", - "Vim script": "#199f4b", - "Visual Basic .NET": "#945db7", - "Volt": "#1F1F1F", - "Vue": "#2c3e50", - "WebAssembly": "#04133b", - "Wollok": "#a23738", - "X10": "#4B6BEF", - "XC": "#99DA07", - "XQuery": "#5232e7", - "XSLT": "#EB8CEB", - "YARA": "#220000", - "YASnippet": "#32AB90", - "Yacc": "#4B6C4B", - "ZAP": "#0d665e", - "ZIL": "#dc75e5", - "ZenScript": "#00BCD1", - "Zephir": "#118f9e", - "Zig": "#ec915c", - "eC": "#913960", - "mIRC Script": "#926059", - "mcfunction": "#E22837", - "nesC": "#94B0C7", - "ooc": "#b0b77e", - "q": "#0040cd", - "sed": "#64b970", - "wdl": "#42f1f4", - "wisp": "#7582D1", - "xBase": "#403a40", -} + "1C Enterprise": "#814CCC", + ABAP: "#E8274B", + "AGS Script": "#B9D9FF", + AMPL: "#E6EFBB", + ANTLR: "#9DC3FF", + "API Blueprint": "#2ACCA8", + APL: "#5A8164", + ASP: "#6a40fd", + ATS: "#1ac620", + ActionScript: "#882B0F", + Ada: "#02f88c", + Agda: "#315665", + Alloy: "#64C800", + AngelScript: "#C7D7DC", + AppleScript: "#101F1F", + Arc: "#aa2afe", + AspectJ: "#a957b0", + Assembly: "#6E4C13", + Asymptote: "#4a0c0c", + AutoHotkey: "#6594b9", + AutoIt: "#1C3552", + Ballerina: "#FF5000", + Batchfile: "#C1F12E", + BlitzMax: "#cd6400", + Boo: "#d4bec1", + Brainfuck: "#2F2530", + C: "#555555", + "C#": "#178600", + "C++": "#f34b7d", + CSS: "#563d7c", + Ceylon: "#dfa535", + Chapel: "#8dc63f", + Cirru: "#ccccff", + Clarion: "#db901e", + Clean: "#3F85AF", + Click: "#E4E6F3", + Clojure: "#db5855", + CoffeeScript: "#244776", + ColdFusion: "#ed2cd6", + "Common Lisp": "#3fb68b", + "Common Workflow Language": "#B5314C", + "Component Pascal": "#B0CE4E", + Crystal: "#000100", + Cuda: "#3A4E3A", + D: "#ba595e", + DM: "#447265", + Dart: "#00B4AB", + DataWeave: "#003a52", + Dhall: "#dfafff", + Dockerfile: "#384d54", + Dogescript: "#cca760", + Dylan: "#6c616e", + E: "#ccce35", + ECL: "#8a1267", + EQ: "#a78649", + Eiffel: "#946d57", + Elixir: "#6e4a7e", + Elm: "#60B5CC", + "Emacs Lisp": "#c065db", + EmberScript: "#FFF4F3", + Erlang: "#B83998", + "F#": "#b845fc", + "F*": "#572e30", + FLUX: "#88ccff", + Factor: "#636746", + Fancy: "#7b9db4", + Fantom: "#14253c", + Faust: "#c37240", + Forth: "#341708", + Fortran: "#4d41b1", + FreeMarker: "#0050b2", + Frege: "#00cafe", + "G-code": "#D08CF2", + GAML: "#FFC766", + GDScript: "#355570", + "Game Maker Language": "#71b417", + Genie: "#fb855d", + Gherkin: "#5B2063", + Glyph: "#c1ac7f", + Gnuplot: "#f0a9f0", + Go: "#00ADD8", + Golo: "#88562A", + Gosu: "#82937f", + "Grammatical Framework": "#79aa7a", + Groovy: "#e69f56", + HTML: "#e34c26", + Hack: "#878787", + Harbour: "#0e60e3", + Haskell: "#5e5086", + Haxe: "#df7900", + HiveQL: "#dce200", + HolyC: "#ffefaf", + Hy: "#7790B2", + IDL: "#a3522f", + "IGOR Pro": "#0000cc", + Idris: "#b30000", + Io: "#a9188d", + Ioke: "#078193", + Isabelle: "#FEFE00", + J: "#9EEDFF", + JSONiq: "#40d47e", + Java: "#b07219", + JavaScript: "#f1e05a", + Jolie: "#843179", + Jsonnet: "#0064bd", + Julia: "#a270ba", + "Jupyter Notebook": "#DA5B0B", + KRL: "#28430A", + Kotlin: "#F18E33", + LFE: "#4C3023", + LLVM: "#185619", + LOLCODE: "#cc9900", + LSL: "#3d9970", + Lasso: "#999999", + Lex: "#DBCA00", + LiveScript: "#499886", + LookML: "#652B81", + Lua: "#000080", + MATLAB: "#e16737", + MAXScript: "#00a6a6", + MLIR: "#5EC8DB", + MQL4: "#62A8D6", + MQL5: "#4A76B8", + MTML: "#b7e1f4", + Makefile: "#427819", + Mask: "#f97732", + Max: "#c4a79c", + Mercury: "#ff2b2b", + Meson: "#007800", + Metal: "#8f14e9", + Mirah: "#c7a938", + "Modula-3": "#223388", + NCL: "#28431f", + Nearley: "#990000", + Nemerle: "#3d3c6e", + NetLinx: "#0aa0ff", + "NetLinx+ERB": "#747faa", + NetLogo: "#ff6375", + NewLisp: "#87AED7", + Nextflow: "#3ac486", + Nim: "#37775b", + Nit: "#009917", + Nix: "#7e7eff", + Nu: "#c9df40", + OCaml: "#3be133", + ObjectScript: "#424893", + "Objective-C": "#438eff", + "Objective-C++": "#6866fb", + "Objective-J": "#ff0c5a", + Odin: "#60AFFE", + Omgrofl: "#cabbff", + Opal: "#f7ede0", + OpenQASM: "#AA70FF", + Oxygene: "#cdd0e3", + Oz: "#fab738", + P4: "#7055b5", + PHP: "#4F5D95", + PLSQL: "#dad8d8", + Pan: "#cc0000", + Papyrus: "#6600cc", + Parrot: "#f3ca0a", + Pascal: "#E3F171", + Pawn: "#dbb284", + Pep8: "#C76F5B", + Perl: "#0298c3", + PigLatin: "#fcd7de", + Pike: "#005390", + PogoScript: "#d80074", + PostScript: "#da291c", + PowerBuilder: "#8f0f8d", + PowerShell: "#012456", + Processing: "#0096D8", + Prolog: "#74283c", + "Propeller Spin": "#7fa2a7", + Puppet: "#302B6D", + PureBasic: "#5a6986", + PureScript: "#1D222D", + Python: "#3572A5", + QML: "#44a51c", + Quake: "#882233", + R: "#198CE7", + RAML: "#77d9fb", + RUNOFF: "#665a4e", + Racket: "#3c5caa", + Ragel: "#9d5200", + Raku: "#0000fb", + Rascal: "#fffaa0", + Reason: "#ff5847", + Rebol: "#358a5b", + Red: "#f50000", + "Ren'Py": "#ff7f7f", + Ring: "#2D54CB", + Riot: "#A71E49", + Roff: "#ecdebe", + Rouge: "#cc0088", + Ruby: "#701516", + Rust: "#dea584", + SAS: "#B34936", + SQF: "#3F3F3F", + "SRecode Template": "#348a34", + SaltStack: "#646464", + Scala: "#c22d40", + Scheme: "#1e4aec", + Self: "#0579aa", + Shell: "#89e051", + Shen: "#120F14", + Slash: "#007eff", + Slice: "#003fa2", + SmPL: "#c94949", + Smalltalk: "#596706", + Solidity: "#AA6746", + SourcePawn: "#5c7611", + Squirrel: "#800000", + Stan: "#b2011d", + "Standard ML": "#dc566d", + Starlark: "#76d275", + SuperCollider: "#46390b", + Swift: "#ffac45", + SystemVerilog: "#DAE1C2", + "TI Program": "#A0AA87", + Tcl: "#e4cc98", + TeX: "#3D6117", + Terra: "#00004c", + Turing: "#cf142b", + TypeScript: "#2b7489", + UnrealScript: "#a54c4d", + V: "#5d87bd", + VBA: "#867db1", + VBScript: "#15dcdc", + VCL: "#148AA8", + VHDL: "#adb2cb", + Vala: "#fbe5cd", + Verilog: "#b2b7f8", + "Vim script": "#199f4b", + "Visual Basic .NET": "#945db7", + Volt: "#1F1F1F", + Vue: "#2c3e50", + WebAssembly: "#04133b", + Wollok: "#a23738", + X10: "#4B6BEF", + XC: "#99DA07", + XQuery: "#5232e7", + XSLT: "#EB8CEB", + YARA: "#220000", + YASnippet: "#32AB90", + Yacc: "#4B6C4B", + ZAP: "#0d665e", + ZIL: "#dc75e5", + ZenScript: "#00BCD1", + Zephir: "#118f9e", + Zig: "#ec915c", + eC: "#913960", + "mIRC Script": "#926059", + mcfunction: "#E22837", + nesC: "#94B0C7", + ooc: "#b0b77e", + q: "#0040cd", + sed: "#64b970", + wdl: "#42f1f4", + wisp: "#7582D1", + xBase: "#403a40", +}; -function getLabel(isZh,key){ - if(isZh){ - return zhCN[key] - }else{ - return esUN[key] - } +function getLabel(isZh, key) { + if (isZh) { + return zhCN[key]; + } else { + return esUN[key]; + } } -var zhCN={ - "search":"搜索", - "search_repo":"项目", - "search_dataset":"数据集", - "search_issue":"任务", - "search_pr":"合并请求", - "search_user":"用户", - "search_org":"组织", - "search_finded":"找到", - "search_matched":"最佳匹配", - "search_matched_download":"下载次数", - "search_lasted_update":"最后更新于", - "search_letter_asc":"字母顺序排序", - "search_letter_desc":"字母逆序排序", - "search_lasted_create":"最近创建", - "search_early_create":"最早创建", - "search_add_by":"加入于", - "search_lasted":"最近更新", - "search_open":"开启中", - "search_closed":"已关闭", - "search_watched":"关注数", - "search_star":"点赞数", - "search_fork":"Fork数", - "search_input_large_0":"请输入大于0的数值。", - "search_input_maxed":"不能超出总页数。", - "search_input_total":"共", - "search_srtip":"条", - "search_home_page":"首页", - "search_last_page":"末页", - "search_go_to":"前往", - "search_go_page":"页", - "find_title":"“{keyword}”相关{tablename}约为{total}个", - "search_empty":"请输入任意关键字开始搜索。" - } - - var esUN={ - "search":"Search", - "search_repo":"Repository", - "search_dataset":"DataSet", - "search_issue":"Issue", - "search_pr":"Pull Request", - "search_user":"User", - "search_org":"Organization", - "search_finded":"Find", - "search_matched":"Best Match", - "search_matched_download":"Most downloads", - "search_lasted_update":"Updated ", - "search_letter_asc":"Alphabetically", - "search_letter_desc":"Reverse alphabetically", - "search_lasted_create":"Recently created", - "search_early_create":"First created", - "search_add_by":"Joined on", - "search_lasted":"Recently updated", - "search_open":"Open", - "search_closed":"Closed", - "search_watched":"Watches", - "search_star":"Stars", - "search_fork":"Forks", - "search_input_large_0":"Please enter a value greater than 0.", - "search_input_maxed":"Cannot exceed total pages.", - "search_input_total":"Total", - "search_srtip":"", - "search_home_page":"First", - "search_last_page":"Last", - "search_go_to":"Go", - "search_go_page":"Page", - "find_title":" {total} \"{keyword}\" related {tablename}", - "search_empty":"Please enter any keyword to start the search." - } - initDiv(false); - document.onreadystatechange = function() { - if (document.readyState === "complete") { - var tmpSearchLabel = sessionStorage.getItem("searchLabel"); - console.log("tmpSearchLabel=" + tmpSearchLabel); - if(tmpSearchLabel){ - console.log("search label...."); - sessionStorage.removeItem("searchLabel"); - doSearchLabel(sessionStorage.getItem("tableName"),sessionStorage.getItem("keyword"),sessionStorage.getItem("sortBy"),sessionStorage.getItem("ascending")); - }else{ - var specifySearch = sessionStorage.getItem("specifySearch"); - if(specifySearch){ - sessionStorage.removeItem("specifySearch"); - console.log("search sepcial keyword=...." + sessionStorage.getItem("keyword")); - document.getElementById("keyword_input").value = sessionStorage.getItem("keyword"); - doSpcifySearch(sessionStorage.getItem("tableName"),sessionStorage.getItem("keyword"),sessionStorage.getItem("sortBy"),sessionStorage.getItem("ascending")); - }else{ - console.log("normal search...."); - search(); - } - - } - } - } +var zhCN = { + search: "搜索", + search_repo: "项目", + search_dataset: "数据集", + search_issue: "任务", + search_pr: "合并请求", + search_user: "用户", + search_org: "组织", + search_finded: "找到", + search_matched: "最佳匹配", + search_matched_download: "下载次数", + search_lasted_update: "最后更新于", + search_letter_asc: "字母顺序排序", + search_letter_desc: "字母逆序排序", + search_lasted_create: "最近创建", + search_early_create: "最早创建", + search_add_by: "加入于", + search_lasted: "最近更新", + search_open: "开启中", + search_closed: "已关闭", + search_watched: "关注数", + search_star: "点赞数", + search_fork: "Fork数", + search_input_large_0: "请输入大于0的数值。", + search_input_maxed: "不能超出总页数。", + search_input_total: "共", + search_srtip: "条", + search_home_page: "首页", + search_last_page: "末页", + search_go_to: "前往", + search_go_page: "页", + find_title: + '“{keyword}”相关{tablename}约为{total}个', + search_empty: "请输入任意关键字开始搜索。", +}; - +var esUN = { + search: "Search", + search_repo: "Repository", + search_dataset: "DataSet", + search_issue: "Issue", + search_pr: "Pull Request", + search_user: "User", + search_org: "Organization", + search_finded: "Find", + search_matched: "Best Match", + search_matched_download: "Most downloads", + search_lasted_update: "Updated ", + search_letter_asc: "Alphabetically", + search_letter_desc: "Reverse alphabetically", + search_lasted_create: "Recently created", + search_early_create: "First created", + search_add_by: "Joined on", + search_lasted: "Recently updated", + search_open: "Open", + search_closed: "Closed", + search_watched: "Watches", + search_star: "Stars", + search_fork: "Forks", + search_input_large_0: "Please enter a value greater than 0.", + search_input_maxed: "Cannot exceed total pages.", + search_input_total: "Total", + search_srtip: "", + search_home_page: "First", + search_last_page: "Last", + search_go_to: "Go", + search_go_page: "Page", + find_title: + ' {total} "{keyword}" related {tablename}', + search_empty: + "Please enter any keyword to start the search.", +}; +initDiv(false); +document.onreadystatechange = function () { + if (document.readyState === "complete") { + var tmpSearchLabel = sessionStorage.getItem("searchLabel"); + if (tmpSearchLabel) { + sessionStorage.removeItem("searchLabel"); + doSearchLabel( + sessionStorage.getItem("tableName"), + sessionStorage.getItem("keyword"), + sessionStorage.getItem("sortBy"), + sessionStorage.getItem("ascending") + ); + } else { + var specifySearch = sessionStorage.getItem("specifySearch"); + if (specifySearch) { + sessionStorage.removeItem("specifySearch"); + document.getElementById("keyword_input").value = + sessionStorage.getItem("keyword"); + doSpcifySearch( + sessionStorage.getItem("tableName"), + sessionStorage.getItem("keyword"), + sessionStorage.getItem("sortBy"), + sessionStorage.getItem("ascending") + ); + } else { + search(); + } + } + } +}; diff --git a/public/self/js/notebook/es5-shim.min.js b/public/self/js/notebook/es5-shim.min.js index f301219d9..bd2883959 100644 --- a/public/self/js/notebook/es5-shim.min.js +++ b/public/self/js/notebook/es5-shim.min.js @@ -4,4 +4,3 @@ * see https://github.com/es-shims/es5-shim/blob/master/LICENSE */ (function(t,r){"use strict";if(typeof define==="function"&&define.amd){define(r)}else if(typeof exports==="object"){module.exports=r()}else{t.returnExports=r()}})(this,function(){var t=Array;var r=t.prototype;var e=Object;var n=e.prototype;var i=Function;var a=i.prototype;var o=String;var f=o.prototype;var u=Number;var l=u.prototype;var s=r.slice;var c=r.splice;var v=r.push;var h=r.unshift;var p=r.concat;var y=r.join;var d=a.call;var g=a.apply;var w=Math.max;var b=Math.min;var T=n.toString;var m=typeof Symbol==="function"&&typeof Symbol.toStringTag==="symbol";var D;var S=Function.prototype.toString,x=/^\s*class /,O=function isES6ClassFn(t){try{var r=S.call(t);var e=r.replace(/\/\/.*\n/g,"");var n=e.replace(/\/\*[.\s\S]*\*\//g,"");var i=n.replace(/\n/gm," ").replace(/ {2}/g," ");return x.test(i)}catch(a){return false}},E=function tryFunctionObject(t){try{if(O(t)){return false}S.call(t);return true}catch(r){return false}},j="[object Function]",I="[object GeneratorFunction]",D=function isCallable(t){if(!t){return false}if(typeof t!=="function"&&typeof t!=="object"){return false}if(m){return E(t)}if(O(t)){return false}var r=T.call(t);return r===j||r===I};var M;var U=RegExp.prototype.exec,$=function tryRegexExec(t){try{U.call(t);return true}catch(r){return false}},F="[object RegExp]";M=function isRegex(t){if(typeof t!=="object"){return false}return m?$(t):T.call(t)===F};var N;var C=String.prototype.valueOf,k=function tryStringObject(t){try{C.call(t);return true}catch(r){return false}},A="[object String]";N=function isString(t){if(typeof t==="string"){return true}if(typeof t!=="object"){return false}return m?k(t):T.call(t)===A};var R=e.defineProperty&&function(){try{var t={};e.defineProperty(t,"x",{enumerable:false,value:t});for(var r in t){return false}return t.x===t}catch(n){return false}}();var P=function(t){var r;if(R){r=function(t,r,n,i){if(!i&&r in t){return}e.defineProperty(t,r,{configurable:true,enumerable:false,writable:true,value:n})}}else{r=function(t,r,e,n){if(!n&&r in t){return}t[r]=e}}return function defineProperties(e,n,i){for(var a in n){if(t.call(n,a)){r(e,a,n[a],i)}}}}(n.hasOwnProperty);var J=function isPrimitive(t){var r=typeof t;return t===null||r!=="object"&&r!=="function"};var Y=u.isNaN||function isActualNaN(t){return t!==t};var z={ToInteger:function ToInteger(t){var r=+t;if(Y(r)){r=0}else if(r!==0&&r!==1/0&&r!==-(1/0)){r=(r>0||-1)*Math.floor(Math.abs(r))}return r},ToPrimitive:function ToPrimitive(t){var r,e,n;if(J(t)){return t}e=t.valueOf;if(D(e)){r=e.call(t);if(J(r)){return r}}n=t.toString;if(D(n)){r=n.call(t);if(J(r)){return r}}throw new TypeError},ToObject:function(t){if(t==null){throw new TypeError("can't convert "+t+" to object")}return e(t)},ToUint32:function ToUint32(t){return t>>>0}};var Z=function Empty(){};P(a,{bind:function bind(t){var r=this;if(!D(r)){throw new TypeError("Function.prototype.bind called on incompatible "+r)}var n=s.call(arguments,1);var a;var o=function(){if(this instanceof a){var i=g.call(r,this,p.call(n,s.call(arguments)));if(e(i)===i){return i}return this}else{return g.call(r,t,p.call(n,s.call(arguments)))}};var f=w(0,r.length-n.length);var u=[];for(var l=0;l0){r[e]=t[e]}return q(r,L(arguments,1))};B=function arraySliceApplyIE(t,r){return q(W(t),r)}}}var K=d.bind(f.slice);var Q=d.bind(f.split);var V=d.bind(f.indexOf);var _=d.bind(v);var tt=d.bind(n.propertyIsEnumerable);var rt=d.bind(r.sort);var et=t.isArray||function isArray(t){return H(t)==="[object Array]"};var nt=[].unshift(0)!==1;P(r,{unshift:function(){h.apply(this,arguments);return this.length}},nt);P(t,{isArray:et});var it=e("a");var at=it[0]!=="a"||!(0 in it);var ot=function properlyBoxed(t){var r=true;var e=true;var n=false;if(t){try{t.call("foo",function(t,e,n){if(typeof n!=="object"){r=false}});t.call([1],function(){"use strict";e=typeof this==="string"},"x")}catch(i){n=true}}return!!t&&!n&&r&&e};P(r,{forEach:function forEach(t){var r=z.ToObject(this);var e=at&&N(this)?Q(this,""):r;var n=-1;var i=z.ToUint32(e.length);var a;if(arguments.length>1){a=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.forEach callback must be a function")}while(++n1){o=arguments[1]}if(!D(r)){throw new TypeError("Array.prototype.map callback must be a function")}for(var f=0;f1){o=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.filter callback must be a function")}for(var f=0;f1){i=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.every callback must be a function")}for(var a=0;a1){i=arguments[1]}if(!D(t)){throw new TypeError("Array.prototype.some callback must be a function")}for(var a=0;a=2){a=arguments[1]}else{do{if(i in e){a=e[i++];break}if(++i>=n){throw new TypeError("reduce of empty array with no initial value")}}while(true)}for(;i=2){i=arguments[1]}else{do{if(a in e){i=e[a--];break}if(--a<0){throw new TypeError("reduceRight of empty array with no initial value")}}while(true)}if(a<0){return i}do{if(a in e){i=t(i,e[a],a,r)}}while(a--);return i}},!ut);var lt=r.indexOf&&[0,1].indexOf(1,2)!==-1;P(r,{indexOf:function indexOf(t){var r=at&&N(this)?Q(this,""):z.ToObject(this);var e=z.ToUint32(r.length);if(e===0){return-1}var n=0;if(arguments.length>1){n=z.ToInteger(arguments[1])}n=n>=0?n:w(0,e+n);for(;n1){n=b(n,z.ToInteger(arguments[1]))}n=n>=0?n:e-Math.abs(n);for(;n>=0;n--){if(n in r&&t===r[n]){return n}}return-1}},st);var ct=function(){var t=[1,2];var r=t.splice();return t.length===2&&et(r)&&r.length===0}();P(r,{splice:function splice(t,r){if(arguments.length===0){return[]}else{return c.apply(this,arguments)}}},!ct);var vt=function(){var t={};r.splice.call(t,0,0,1);return t.length===1}();P(r,{splice:function splice(t,r){if(arguments.length===0){return[]}var e=arguments;this.length=w(z.ToInteger(this.length),0);if(arguments.length>0&&typeof r!=="number"){e=W(arguments);if(e.length<2){_(e,this.length-t)}else{e[1]=z.ToInteger(r)}}return c.apply(this,e)}},!vt);var ht=function(){var r=new t(1e5);r[8]="x";r.splice(1,1);return r.indexOf("x")===7}();var pt=function(){var t=256;var r=[];r[t]="a";r.splice(t+1,0,"b");return r[t]==="a"}();P(r,{splice:function splice(t,r){var e=z.ToObject(this);var n=[];var i=z.ToUint32(e.length);var a=z.ToInteger(t);var f=a<0?w(i+a,0):b(a,i);var u=arguments.length===0?0:arguments.length===1?i-f:b(w(z.ToInteger(r),0),i-f);var l=0;var s;while(ly){delete e[l-1];l-=1}}else if(v>u){l=i-u;while(l>f){s=o(l+u-1);h=o(l+v-1);if(G(e,s)){e[h]=e[s]}else{delete e[h]}l-=1}}l=f;for(var d=0;d=0&&!et(t)&&D(t.callee)};var kt=Nt(arguments)?Nt:Ct;P(e,{keys:function keys(t){var r=D(t);var e=kt(t);var n=t!==null&&typeof t==="object";var i=n&&N(t);if(!n&&!r&&!e){throw new TypeError("Object.keys called on a non-object")}var a=[];var f=Ot&&r;if(i&&Et||e){for(var u=0;u11){return t+1}return t},getMonth:function getMonth(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=Bt(this);var r=Xt(this);if(t<0&&r>11){return 0}return r},getDate:function getDate(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=Bt(this);var r=Xt(this);var e=Lt(this);if(t<0&&r>11){if(r===12){return e}var n=ar(0,t+1);return n-e+1}return e},getUTCFullYear:function getUTCFullYear(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=qt(this);if(t<0&&Kt(this)>11){return t+1}return t},getUTCMonth:function getUTCMonth(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=qt(this);var r=Kt(this);if(t<0&&r>11){return 0}return r},getUTCDate:function getUTCDate(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=qt(this);var r=Kt(this);var e=Qt(this);if(t<0&&r>11){if(r===12){return e}var n=ar(0,t+1);return n-e+1}return e}},Jt);P(Date.prototype,{toUTCString:function toUTCString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=Vt(this);var r=Qt(this);var e=Kt(this);var n=qt(this);var i=_t(this);var a=tr(this);var o=rr(this);return nr[t]+", "+(r<10?"0"+r:r)+" "+ir[e]+" "+n+" "+(i<10?"0"+i:i)+":"+(a<10?"0"+a:a)+":"+(o<10?"0"+o:o)+" GMT"}},Jt||Zt);P(Date.prototype,{toDateString:function toDateString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=this.getDay();var r=this.getDate();var e=this.getMonth();var n=this.getFullYear();return nr[t]+" "+ir[e]+" "+(r<10?"0"+r:r)+" "+n}},Jt||Gt);if(Jt||Ht){Date.prototype.toString=function toString(){if(!this||!(this instanceof Date)){throw new TypeError("this is not a Date object.")}var t=this.getDay();var r=this.getDate();var e=this.getMonth();var n=this.getFullYear();var i=this.getHours();var a=this.getMinutes();var o=this.getSeconds();var f=this.getTimezoneOffset();var u=Math.floor(Math.abs(f)/60);var l=Math.floor(Math.abs(f)%60);return nr[t]+" "+ir[e]+" "+(r<10?"0"+r:r)+" "+n+" "+(i<10?"0"+i:i)+":"+(a<10?"0"+a:a)+":"+(o<10?"0"+o:o)+" GMT"+(f>0?"-":"+")+(u<10?"0"+u:u)+(l<10?"0"+l:l)};if(R){e.defineProperty(Date.prototype,"toString",{configurable:true,enumerable:false,writable:true})}}var or=-621987552e5;var fr="-000001";var ur=Date.prototype.toISOString&&new Date(or).toISOString().indexOf(fr)===-1;var lr=Date.prototype.toISOString&&new Date(-1).toISOString()!=="1969-12-31T23:59:59.999Z";var sr=d.bind(Date.prototype.getTime);P(Date.prototype,{toISOString:function toISOString(){if(!isFinite(this)||!isFinite(sr(this))){throw new RangeError("Date.prototype.toISOString called on non-finite value.")}var t=qt(this);var r=Kt(this);t+=Math.floor(r/12);r=(r%12+12)%12;var e=[r+1,Qt(this),_t(this),tr(this),rr(this)];t=(t<0?"-":t>9999?"+":"")+K("00000"+Math.abs(t),0<=t&&t<=9999?-4:-6);for(var n=0;n=7&&l>yr){var p=Math.floor(l/yr)*yr;var y=Math.floor(p/1e3);v+=y;h-=y*1e3}c=s===1&&o(e)===e?new t(r.parse(e)):s>=7?new t(e,n,i,a,f,v,h):s>=6?new t(e,n,i,a,f,v):s>=5?new t(e,n,i,a,f):s>=4?new t(e,n,i,a):s>=3?new t(e,n,i):s>=2?new t(e,n):s>=1?new t(e instanceof t?+e:e):new t}else{c=t.apply(this,arguments)}if(!J(c)){P(c,{constructor:r},true)}return c};var e=new RegExp("^"+"(\\d{4}|[+-]\\d{6})"+"(?:-(\\d{2})"+"(?:-(\\d{2})"+"(?:"+"T(\\d{2})"+":(\\d{2})"+"(?:"+":(\\d{2})"+"(?:(\\.\\d{1,}))?"+")?"+"("+"Z|"+"(?:"+"([-+])"+"(\\d{2})"+":(\\d{2})"+")"+")?)?)?)?"+"$");var n=[0,31,59,90,120,151,181,212,243,273,304,334,365];var i=function dayFromMonth(t,r){var e=r>1?1:0;return n[r]+Math.floor((t-1969+e)/4)-Math.floor((t-1901+e)/100)+Math.floor((t-1601+e)/400)+365*(t-1970)};var a=function toUTC(r){var e=0;var n=r;if(dr&&n>yr){var i=Math.floor(n/yr)*yr;var a=Math.floor(i/1e3);e+=a;n-=a*1e3}return u(new t(1970,0,1,0,0,e,n))};for(var f in t){if(G(t,f)){r[f]=t[f]}}P(r,{now:t.now,UTC:t.UTC},true);r.prototype=t.prototype;P(r.prototype,{constructor:r},true);var l=function parse(r){var n=e.exec(r);if(n){var o=u(n[1]),f=u(n[2]||1)-1,l=u(n[3]||1)-1,s=u(n[4]||0),c=u(n[5]||0),v=u(n[6]||0),h=Math.floor(u(n[7]||0)*1e3),p=Boolean(n[4]&&!n[8]),y=n[9]==="-"?1:-1,d=u(n[10]||0),g=u(n[11]||0),w;var b=c>0||v>0||h>0;if(s<(b?24:25)&&c<60&&v<60&&h<1e3&&f>-1&&f<12&&d<24&&g<60&&l>-1&&l=0){e+=wr.data[r];wr.data[r]=Math.floor(e/t);e=e%t*wr.base}},numToString:function numToString(){var t=wr.size;var r="";while(--t>=0){if(r!==""||t===0||wr.data[t]!==0){var e=o(wr.data[t]);if(r===""){r=e}else{r+=K("0000000",0,7-e.length)+e}}}return r},pow:function pow(t,r,e){return r===0?e:r%2===1?pow(t,r-1,e*t):pow(t*t,r/2,e)},log:function log(t){var r=0;var e=t;while(e>=4096){r+=12;e/=4096}while(e>=2){r+=1;e/=2}return r}};var br=function toFixed(t){var r,e,n,i,a,f,l,s;r=u(t);r=Y(r)?0:Math.floor(r);if(r<0||r>20){throw new RangeError("Number.toFixed called with invalid number of decimals")}e=u(this);if(Y(e)){return"NaN"}if(e<=-1e21||e>=1e21){return o(e)}n="";if(e<0){n="-";e=-e}i="0";if(e>1e-21){a=wr.log(e*wr.pow(2,69,1))-69;f=a<0?e*wr.pow(2,-a,1):e/wr.pow(2,a,1);f*=4503599627370496;a=52-a;if(a>0){wr.multiply(0,f);l=r;while(l>=7){wr.multiply(1e7,0);l-=7}wr.multiply(wr.pow(10,l,1),0);l=a-1;while(l>=23){wr.divide(1<<23);l-=23}wr.divide(1<0){s=i.length;if(s<=r){i=n+K("0.0000000000000000000",0,r-s+2)+i}else{i=n+K(i,0,s-r)+"."+K(i,s-r)}}else{i=n+i}return i};P(l,{toFixed:br},gr);var Tr=function(){try{return 1..toPrecision(undefined)==="1"}catch(t){return true}}();var mr=l.toPrecision;P(l,{toPrecision:function toPrecision(t){return typeof t==="undefined"?mr.call(this):mr.call(this,t)}},Tr);if("ab".split(/(?:ab)*/).length!==2||".".split(/(.?)(.?)/).length!==4||"tesst".split(/(s)*/)[1]==="t"||"test".split(/(?:)/,-1).length!==4||"".split(/.?/).length||".".split(/()()/).length>1){(function(){var t=typeof/()??/.exec("")[1]==="undefined";var r=Math.pow(2,32)-1;f.split=function(e,n){var i=String(this);if(typeof e==="undefined"&&n===0){return[]}if(!M(e)){return Q(this,e,n)}var a=[];var o=(e.ignoreCase?"i":"")+(e.multiline?"m":"")+(e.unicode?"u":"")+(e.sticky?"y":""),f=0,u,l,s,c;var h=new RegExp(e.source,o+"g");if(!t){u=new RegExp("^"+h.source+"$(?!\\s)",o)}var p=typeof n==="undefined"?r:z.ToUint32(n);l=h.exec(i);while(l){s=l.index+l[0].length;if(s>f){_(a,K(i,f,l.index));if(!t&&l.length>1){l[0].replace(u,function(){for(var t=1;t1&&l.index=p){break}}if(h.lastIndex===l.index){h.lastIndex++}l=h.exec(i)}if(f===i.length){if(c||!h.test("")){_(a,"")}}else{_(a,K(i,f))}return a.length>p?W(a,0,p):a}})()}else if("0".split(void 0,0).length){f.split=function split(t,r){if(typeof t==="undefined"&&r===0){return[]}return Q(this,t,r)}}var Dr=f.replace;var Sr=function(){var t=[];"x".replace(/x(.)?/g,function(r,e){_(t,e)});return t.length===1&&typeof t[0]==="undefined"}();if(!Sr){f.replace=function replace(t,r){var e=D(r);var n=M(t)&&/\)[*?]/.test(t.source);if(!e||!n){return Dr.call(this,t,r)}else{var i=function(e){var n=arguments.length;var i=t.lastIndex;t.lastIndex=0;var a=t.exec(e)||[];t.lastIndex=i;_(a,arguments[n-2],arguments[n-1]);return r.apply(this,a)};return Dr.call(this,t,i)}}}var xr=f.substr;var Or="".substr&&"0b".substr(-1)!=="b";P(f,{substr:function substr(t,r){var e=t;if(t<0){e=w(this.length+t,0)}return xr.call(this,e,r)}},Or);var Er="\t\n\x0B\f\r \xa0\u1680\u180e\u2000\u2001\u2002\u2003"+"\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\u2028"+"\u2029\ufeff";var jr="\u200b";var Ir="["+Er+"]";var Mr=new RegExp("^"+Ir+Ir+"*");var Ur=new RegExp(Ir+Ir+"*$");var $r=f.trim&&(Er.trim()||!jr.trim());P(f,{trim:function trim(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}return o(this).replace(Mr,"").replace(Ur,"")}},$r);var Fr=d.bind(String.prototype.trim);var Nr=f.lastIndexOf&&"abc\u3042\u3044".lastIndexOf("\u3042\u3044",2)!==-1;P(f,{lastIndexOf:function lastIndexOf(t){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}var r=o(this);var e=o(t);var n=arguments.length>1?u(arguments[1]):NaN;var i=Y(n)?Infinity:z.ToInteger(n);var a=b(w(i,0),r.length);var f=e.length;var l=a+f;while(l>0){l=w(0,l-f);var s=V(K(r,l,a+f),e);if(s!==-1){return l+s}}return-1}},Nr);var Cr=f.lastIndexOf;P(f,{lastIndexOf:function lastIndexOf(t){return Cr.apply(this,arguments)}},f.lastIndexOf.length!==1);if(parseInt(Er+"08")!==8||parseInt(Er+"0x16")!==22){parseInt=function(t){var r=/^[-+]?0[xX]/;return function parseInt(e,n){if(typeof e==="symbol"){""+e}var i=Fr(String(e));var a=u(n)||(r.test(i)?16:10);return t(i,a)}}(parseInt)}if(1/parseFloat("-0")!==-Infinity){parseFloat=function(t){return function parseFloat(r){var e=Fr(String(r));var n=t(e);return n===0&&K(e,0,1)==="-"?-0:n}}(parseFloat)}if(String(new RangeError("test"))!=="RangeError: test"){var kr=function toString(){if(typeof this==="undefined"||this===null){throw new TypeError("can't convert "+this+" to object")}var t=this.name;if(typeof t==="undefined"){t="Error"}else if(typeof t!=="string"){t=o(t)}var r=this.message;if(typeof r==="undefined"){r=""}else if(typeof r!=="string"){r=o(r)}if(!t){return r}if(!r){return t}return t+": "+r};Error.prototype.toString=kr}if(R){var Ar=function(t,r){if(tt(t,r)){var e=Object.getOwnPropertyDescriptor(t,r);if(e.configurable){e.enumerable=false;Object.defineProperty(t,r,e)}}};Ar(Error.prototype,"message");if(Error.prototype.message!==""){Error.prototype.message=""}Ar(Error.prototype,"name")}if(String(/a/gim)!=="/a/gim"){var Rr=function toString(){var t="/"+this.source+"/";if(this.global){t+="g"}if(this.ignoreCase){t+="i"}if(this.multiline){t+="m"}return t};RegExp.prototype.toString=Rr}}); -//# sourceMappingURL=es5-shim.map diff --git a/public/self/js/notebook/purify.min.js b/public/self/js/notebook/purify.min.js index 8c121b491..30d29f6c2 100644 --- a/public/self/js/notebook/purify.min.js +++ b/public/self/js/notebook/purify.min.js @@ -1,3 +1,2 @@ /*! @license DOMPurify | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/2.2.2/LICENSE */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).DOMPurify=t()}(this,(function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.getPrototypeOf,o=Object.getOwnPropertyDescriptor,i=Object.freeze,a=Object.seal,l=Object.create,c="undefined"!=typeof Reflect&&Reflect,s=c.apply,u=c.construct;s||(s=function(e,t,n){return e.apply(t,n)}),i||(i=function(e){return e}),a||(a=function(e){return e}),u||(u=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1?n-1:0),o=1;o/gm),U=a(/^data-[\-\w.\u00B7-\uFFFF]/),j=a(/^aria-[\-\w]+$/),P=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),B=a(/^(?:\w+script|data):/i),W=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function q(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:K(),n=function(t){return e(t)};if(n.version="2.2.6",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,o=t.document,a=t.DocumentFragment,l=t.HTMLTemplateElement,c=t.Node,s=t.Element,u=t.NodeFilter,f=t.NamedNodeMap,x=void 0===f?t.NamedNodeMap||t.MozNamedAttrMap:f,Y=t.Text,X=t.Comment,$=t.DOMParser,Z=t.trustedTypes,J=s.prototype,Q=k(J,"cloneNode"),ee=k(J,"nextSibling"),te=k(J,"childNodes"),ne=k(J,"parentNode");if("function"==typeof l){var re=o.createElement("template");re.content&&re.content.ownerDocument&&(o=re.content.ownerDocument)}var oe=V(Z,r),ie=oe&&ze?oe.createHTML(""):"",ae=o,le=ae.implementation,ce=ae.createNodeIterator,se=ae.getElementsByTagName,ue=ae.createDocumentFragment,fe=r.importNode,me={};try{me=S(o).documentMode?o.documentMode:{}}catch(e){}var de={};n.isSupported=le&&void 0!==le.createHTMLDocument&&9!==me;var pe=z,ge=H,he=U,ye=j,ve=B,be=W,Te=P,Ae=null,xe=w({},[].concat(q(R),q(_),q(D),q(N),q(L))),we=null,Se=w({},[].concat(q(M),q(F),q(C),q(I))),ke=null,Re=null,_e=!0,De=!0,Ee=!1,Ne=!1,Oe=!1,Le=!1,Me=!1,Fe=!1,Ce=!1,Ie=!0,ze=!1,He=!0,Ue=!0,je=!1,Pe={},Be=w({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),We=null,Ge=w({},["audio","video","img","source","image","track"]),qe=null,Ke=w({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),Ve=null,Ye=o.createElement("form"),Xe=function(e){Ve&&Ve===e||(e&&"object"===(void 0===e?"undefined":G(e))||(e={}),e=S(e),Ae="ALLOWED_TAGS"in e?w({},e.ALLOWED_TAGS):xe,we="ALLOWED_ATTR"in e?w({},e.ALLOWED_ATTR):Se,qe="ADD_URI_SAFE_ATTR"in e?w(S(Ke),e.ADD_URI_SAFE_ATTR):Ke,We="ADD_DATA_URI_TAGS"in e?w(S(Ge),e.ADD_DATA_URI_TAGS):Ge,ke="FORBID_TAGS"in e?w({},e.FORBID_TAGS):{},Re="FORBID_ATTR"in e?w({},e.FORBID_ATTR):{},Pe="USE_PROFILES"in e&&e.USE_PROFILES,_e=!1!==e.ALLOW_ARIA_ATTR,De=!1!==e.ALLOW_DATA_ATTR,Ee=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=e.SAFE_FOR_TEMPLATES||!1,Oe=e.WHOLE_DOCUMENT||!1,Fe=e.RETURN_DOM||!1,Ce=e.RETURN_DOM_FRAGMENT||!1,Ie=!1!==e.RETURN_DOM_IMPORT,ze=e.RETURN_TRUSTED_TYPE||!1,Me=e.FORCE_BODY||!1,He=!1!==e.SANITIZE_DOM,Ue=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,Te=e.ALLOWED_URI_REGEXP||Te,Ne&&(De=!1),Ce&&(Fe=!0),Pe&&(Ae=w({},[].concat(q(L))),we=[],!0===Pe.html&&(w(Ae,R),w(we,M)),!0===Pe.svg&&(w(Ae,_),w(we,F),w(we,I)),!0===Pe.svgFilters&&(w(Ae,D),w(we,F),w(we,I)),!0===Pe.mathMl&&(w(Ae,N),w(we,C),w(we,I))),e.ADD_TAGS&&(Ae===xe&&(Ae=S(Ae)),w(Ae,e.ADD_TAGS)),e.ADD_ATTR&&(we===Se&&(we=S(we)),w(we,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&w(qe,e.ADD_URI_SAFE_ATTR),Ue&&(Ae["#text"]=!0),Oe&&w(Ae,["html","head","body"]),Ae.table&&(w(Ae,["tbody"]),delete ke.tbody),i&&i(e),Ve=e)},$e=w({},["mi","mo","mn","ms","mtext"]),Ze=w({},["foreignobject","desc","title","annotation-xml"]),Je=w({},_);w(Je,D),w(Je,E);var Qe=w({},N);w(Qe,O);var et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",rt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:nt,tagName:"template"});var n=g(e.tagName),r=g(t.tagName);if(e.namespaceURI===tt)return t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===r||$e[r]):Boolean(Je[n]);if(e.namespaceURI===et)return t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&Ze[r]:Boolean(Qe[n]);if(e.namespaceURI===nt){if(t.namespaceURI===tt&&!Ze[r])return!1;if(t.namespaceURI===et&&!$e[r])return!1;var o=w({},["title","style","font","a","script"]);return!Qe[n]&&(o[n]||!Je[n])}return!1},ot=function(e){p(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=ie}catch(t){e.remove()}}},it=function(e,t){try{p(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){p(n.removed,{attribute:null,from:t})}t.removeAttribute(e)},at=function(e){var t=void 0,n=void 0;if(Me)e=""+e;else{var r=h(e,/^[\r\n\t ]+/);n=r&&r[0]}var i=oe?oe.createHTML(e):e;try{t=(new $).parseFromString(i,"text/html")}catch(e){}if(!t||!t.documentElement){var a=(t=le.createHTMLDocument("")).body;a.parentNode.removeChild(a.parentNode.firstElementChild),a.outerHTML=i}return e&&n&&t.body.insertBefore(o.createTextNode(n),t.body.childNodes[0]||null),se.call(t,Oe?"html":"body")[0]},lt=function(e){return ce.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,(function(){return u.FILTER_ACCEPT}),!1)},ct=function(e){return!(e instanceof Y||e instanceof X)&&!("string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof x&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI&&"function"==typeof e.insertBefore)},st=function(e){return"object"===(void 0===c?"undefined":G(c))?e instanceof c:e&&"object"===(void 0===e?"undefined":G(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ut=function(e,t,r){de[e]&&m(de[e],(function(e){e.call(n,t,r,Ve)}))},ft=function(e){var t=void 0;if(ut("beforeSanitizeElements",e,null),ct(e))return ot(e),!0;if(h(e.nodeName,/[\u0080-\uFFFF]/))return ot(e),!0;var r=g(e.nodeName);if(ut("uponSanitizeElement",e,{tagName:r,allowedTags:Ae}),!st(e.firstElementChild)&&(!st(e.content)||!st(e.content.firstElementChild))&&T(/<[/\w]/g,e.innerHTML)&&T(/<[/\w]/g,e.textContent))return ot(e),!0;if(!Ae[r]||ke[r]){if(Ue&&!Be[r])for(var o=ne(e),i=te(e),a=i.length-1;a>=0;--a)o.insertBefore(Q(i[a],!0),ee(e));return ot(e),!0}return e instanceof s&&!rt(e)?(ot(e),!0):"noscript"!==r&&"noembed"!==r||!T(/<\/no(script|embed)/i,e.innerHTML)?(Ne&&3===e.nodeType&&(t=e.textContent,t=y(t,pe," "),t=y(t,ge," "),e.textContent!==t&&(p(n.removed,{element:e.cloneNode()}),e.textContent=t)),ut("afterSanitizeElements",e,null),!1):(ot(e),!0)},mt=function(e,t,n){if(He&&("id"===t||"name"===t)&&(n in o||n in Ye))return!1;if(De&&T(he,t));else if(_e&&T(ye,t));else{if(!we[t]||Re[t])return!1;if(qe[t]);else if(T(Te,y(n,be,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!We[e]){if(Ee&&!T(ve,y(n,be,"")));else if(n)return!1}else;}return!0},dt=function(e){var t=void 0,r=void 0,o=void 0,i=void 0;ut("beforeSanitizeAttributes",e,null);var a=e.attributes;if(a){var l={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:we};for(i=a.length;i--;){var c=t=a[i],s=c.name,u=c.namespaceURI;if(r=b(t.value),o=g(s),l.attrName=o,l.attrValue=r,l.keepAttr=!0,l.forceKeepAttr=void 0,ut("uponSanitizeAttribute",e,l),r=l.attrValue,!l.forceKeepAttr&&(it(s,e),l.keepAttr))if(T(/\/>/i,r))it(s,e);else{Ne&&(r=y(r,pe," "),r=y(r,ge," "));var f=e.nodeName.toLowerCase();if(mt(f,o,r))try{u?e.setAttributeNS(u,s,r):e.setAttribute(s,r),d(n.removed)}catch(e){}}}ut("afterSanitizeAttributes",e,null)}},pt=function e(t){var n=void 0,r=lt(t);for(ut("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)ut("uponSanitizeShadowNode",n,null),ft(n)||(n.content instanceof a&&e(n.content),dt(n));ut("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,o){var i=void 0,l=void 0,s=void 0,u=void 0,f=void 0;if(e||(e="\x3c!--\x3e"),"string"!=typeof e&&!st(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!n.isSupported){if("object"===G(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(st(e))return t.toStaticHTML(e.outerHTML)}return e}if(Le||Xe(o),n.removed=[],"string"==typeof e&&(je=!1),je);else if(e instanceof c)1===(l=(i=at("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===l.nodeName||"HTML"===l.nodeName?i=l:i.appendChild(l);else{if(!Fe&&!Ne&&!Oe&&-1===e.indexOf("<"))return oe&&ze?oe.createHTML(e):e;if(!(i=at(e)))return Fe?null:ie}i&&Me&&ot(i.firstChild);for(var m=lt(je?e:i);s=m.nextNode();)3===s.nodeType&&s===u||ft(s)||(s.content instanceof a&&pt(s.content),dt(s),u=s);if(u=null,je)return e;if(Fe){if(Ce)for(f=ue.call(i.ownerDocument);i.firstChild;)f.appendChild(i.firstChild);else f=i;return Ie&&(f=fe.call(r,f,!0)),f}var d=Oe?i.outerHTML:i.innerHTML;return Ne&&(d=y(d,pe," "),d=y(d,ge," ")),oe&&ze?oe.createHTML(d):d},n.setConfig=function(e){Xe(e),Le=!0},n.clearConfig=function(){Ve=null,Le=!1},n.isValidAttribute=function(e,t,n){Ve||Xe({});var r=g(e),o=g(t);return mt(r,o,n)},n.addHook=function(e,t){"function"==typeof t&&(de[e]=de[e]||[],p(de[e],t))},n.removeHook=function(e){de[e]&&d(de[e])},n.removeHooks=function(e){de[e]&&(de[e]=[])},n.removeAllHooks=function(){de={}},n}()})); -//# sourceMappingURL=purify.min.js.map diff --git a/routers/api/v1/repo/cloudbrain_dashboard.go b/routers/api/v1/repo/cloudbrain_dashboard.go index 07298ffdc..f102a0f05 100644 --- a/routers/api/v1/repo/cloudbrain_dashboard.go +++ b/routers/api/v1/repo/cloudbrain_dashboard.go @@ -67,7 +67,7 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { pagesize := 1000 count := pagesize for count == pagesize && count != 0 { - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: pagesize, @@ -121,6 +121,13 @@ func GetAllCloudbrainsOverview(ctx *context.Context) { } } + cloudBrainTypeList := []int{0, 1, 2} + for _, v := range cloudBrainTypeList { + if _, ok := cloudBrainNum[v]; !ok { + cloudBrainNum[v] = 0 + } + } + todayRunningCount := todayStatusResult[string(models.JobRunning)] todayCompletedCount := todayStatusResult[string(models.ModelArtsTrainJobCompleted)] + todayStatusResult[string(models.JobFailed)] + todayStatusResult[string(models.ModelArtsStartFailed)] + todayStatusResult[string(models.JobStopped)] + todayStatusResult[string(models.JobSucceeded)] + todayStatusResult[string(models.ModelArtsTrainJobKilled)] @@ -504,7 +511,7 @@ func GetAllCloudbrainsPeriodDistribution(ctx *context.Context) { count := pagesize //Each time a maximum of 1000 pieces of data are detected to the memory, batch processing for count == pagesize && count != 0 { - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: pagesize, @@ -613,7 +620,7 @@ func GetCloudbrainsStatusAnalysis(ctx *context.Context) { pagesize := 1000 count := pagesize for count == pagesize && count != 0 { - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ ListOptions: models.ListOptions{ Page: page, PageSize: pagesize, @@ -1021,7 +1028,7 @@ func getCloudbrainCount(beginTime time.Time, endTime time.Time, cloudbrains []*m func getDayCloudbrainNum(beginTime time.Time, endTime time.Time) ([]DateCloudbrainNum, error) { var endTimeTemp time.Time endTimeTemp = beginTime.AddDate(0, 0, 1) - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ Type: models.TypeCloudBrainAll, BeginTimeUnix: beginTime.Unix(), EndTimeUnix: endTime.Unix(), @@ -1057,7 +1064,7 @@ func getMonthCloudbrainNum(beginTime time.Time, endTime time.Time) ([]DateCloudb endTimeTemp = beginTime.AddDate(0, 1, 0) endTimeTemp = time.Date(endTimeTemp.Year(), endTimeTemp.Month(), 1, 0, 0, 0, 0, now.Location()) monthCloudbrainNum := make([]DateCloudbrainNum, 0) - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ Type: models.TypeCloudBrainAll, BeginTimeUnix: beginTime.Unix(), EndTimeUnix: endTime.Unix(), @@ -1093,7 +1100,7 @@ func getDayCloudbrainInfo(beginTime time.Time, endTime time.Time) ([]DateCloudbr if endTimeTemp.Equal(endTime) { endTimeTemp = endTimeTemp.AddDate(0, 0, -1) } - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ Type: models.TypeCloudBrainAll, BeginTimeUnix: beginTime.Unix(), EndTimeUnix: endTime.Unix(), @@ -1124,7 +1131,7 @@ func getMonthCloudbrainInfo(beginTime time.Time, endTime time.Time) ([]DateCloud if endTimeTemp.Equal(endTime) { endTimeTemp = endTimeTemp.AddDate(0, -1, 0) } - cloudbrains, _, err := models.CloudbrainAll(&models.CloudbrainsOptions{ + cloudbrains, _, err := models.CloudbrainAllStatic(&models.CloudbrainsOptions{ Type: models.TypeCloudBrainAll, BeginTimeUnix: beginTime.Unix(), EndTimeUnix: endTime.Unix(), diff --git a/routers/home.go b/routers/home.go index dcd30a139..2b852533a 100755 --- a/routers/home.go +++ b/routers/home.go @@ -7,7 +7,6 @@ package routers import ( "bytes" - "fmt" "net/http" "strconv" "strings" @@ -676,10 +675,19 @@ func getRecommendOrg() ([]map[string]interface{}, error) { if err != nil { return nil, err } + names := make([]string, 0) + for _, userName := range result { + names = append(names, userName) + } + users, _ := models.GetUsersByNames(names) + userMap := make(map[string]*models.User, 0) + for _, user := range users { + userMap[user.Name] = user + } resultOrg := make([]map[string]interface{}, 0) for _, userName := range result { - user, err := models.GetUserByName(userName) - if err == nil { + user := userMap[userName] + if user != nil { userMap := make(map[string]interface{}) userMap["Name"] = user.Name userMap["Description"] = user.Description @@ -692,7 +700,7 @@ func getRecommendOrg() ([]map[string]interface{}, error) { userMap["NumMembers"] = user.NumMembers resultOrg = append(resultOrg, userMap) } else { - log.Info("query user error," + err.Error()) + log.Info("the user not exist," + userName) } } return resultOrg, nil @@ -761,15 +769,6 @@ func GetRankUser(index string) ([]map[string]interface{}, error) { return resultOrg, nil } -// func GetImageInfoFromPromote(ctx *context.Context) { -// imageInfo, err := GetImageInfo() -// if err != nil { -// ctx.ServerError("500", err) -// return -// } -// ctx.JSON(200, imageInfo) -// } - func GetUserRankFromPromote(ctx *context.Context) { index := ctx.Params("index") resultUserRank, err := GetRankUser(index) @@ -793,45 +792,15 @@ func RecommendHomeInfo(ctx *context.Context) { if err != nil { log.Info("error." + err.Error()) } - resultCloudBrain, err := getCloudbrainNums() - if err != nil { - log.Info("error." + err.Error()) - } + mapInterface := make(map[string]interface{}) mapInterface["org"] = resultOrg mapInterface["repo"] = resultRepo mapInterface["image"] = resultImage - mapInterface["cloudbrain"] = resultCloudBrain + //mapInterface["cloudbrain"] = resultCloudBrain ctx.JSON(http.StatusOK, mapInterface) } -func getCloudbrainNums() (map[string]string, error) { - result := make(map[string]string) - cloudStatusMap := models.GetAllStatusCloudBrain() - result["completed_task"] = fmt.Sprint(cloudStatusMap["COMPLETED"]) - result["running_task"] = fmt.Sprint(cloudStatusMap["RUNNING"]) - result["wait_task"] = fmt.Sprint(cloudStatusMap["WAITING"]) - return result, nil -} - -// func RecommendOrgFromPromote(ctx *context.Context) { -// resultOrg, err := GetRecommendOrg() -// if err != nil { -// ctx.ServerError("500", err) -// return -// } -// ctx.JSON(200, resultOrg) -// } - -func RecommendRepoFromPromote(ctx *context.Context) { - result, err := repository.GetRecommendRepoFromPromote("projects") - if err != nil { - ctx.ServerError("500", err) - } else { - ctx.JSON(200, result) - } -} - func HomeTerm(ctx *context.Context) { ctx.HTML(200, tplHomeTerm) } diff --git a/routers/repo/dataset.go b/routers/repo/dataset.go index 08db5a613..97d7a2060 100755 --- a/routers/repo/dataset.go +++ b/routers/repo/dataset.go @@ -172,8 +172,8 @@ func DatasetIndex(ctx *context.Context) { for _, attachment := range pageAttachments { uploader, _ := models.GetUserByID(attachment.UploaderID) attachment.Uploader = uploader - if !strings.HasSuffix(attachment.Name, ".zip") { - attachment.DecompressState = -1 //非zip文件 + if !strings.HasSuffix(attachment.Name, ".zip") && !strings.HasSuffix(attachment.Name, ".tar.gz") { + attachment.DecompressState = -1 //非压缩文件 } } @@ -700,8 +700,14 @@ func DatasetIsCollaborator(ctx *context.Context, dataset *models.Dataset) bool { repo.GetOwner() if ctx.User != nil { if repo.Owner.IsOrganization() { - if repo.Owner.IsUserPartOfOrg(ctx.User.ID) { - for _, t := range repo.Owner.Teams { + org := repo.Owner + org.Teams, err = org.GetUserTeams(ctx.User.ID) + if err != nil { + log.Error("GetUserTeams error:", err.Error()) + return false + } + if org.IsUserPartOfOrg(ctx.User.ID) { + for _, t := range org.Teams { if t.IsMember(ctx.User.ID) && t.HasRepository(repo.ID) { return true } diff --git a/routers/search.go b/routers/search.go index fe1643c80..05074df55 100644 --- a/routers/search.go +++ b/routers/search.go @@ -489,7 +489,7 @@ func makeRepoResult(sRes *elastic.SearchResult, Key string, OnlyReturnNum bool, if recordSource["avatar"] != nil { avatarstr := recordSource["avatar"].(string) if len(avatarstr) == 0 { - record["avatar"] = setting.RepositoryAvatarFallbackImage + // record["avatar"] = setting.RepositoryAvatarFallbackImage } else { record["avatar"] = setting.AppSubURL + "/repo-avatars/" + avatarstr } diff --git a/services/repository/repository.go b/services/repository/repository.go index 80518b666..6bf4ab283 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -131,11 +131,6 @@ func GetRecommendRepoFromPromote(filename string) ([]map[string]interface{}, err repoMap["ID"] = fmt.Sprint(repo.ID) repoMap["Name"] = repo.Name repoMap["Alias"] = repo.Alias - if repo.RepoType == models.RepoCourse { - //Load creator - repo.GetCreator() - repoMap["Creator"] = repo.Creator - } repoMap["OwnerName"] = repo.OwnerName repoMap["NumStars"] = repo.NumStars diff --git a/templates/explore/repo_list.tmpl b/templates/explore/repo_list.tmpl index b6bb49da9..6fca54f46 100755 --- a/templates/explore/repo_list.tmpl +++ b/templates/explore/repo_list.tmpl @@ -1,38 +1,46 @@