본문으로 이동
주 메뉴
주 메뉴
사이드바로 이동
숨기기
둘러보기
대문
최근 바뀜
게임 목록
임의의 게임으로
커뮤니티
리버티게임 본진
리버티게임(개발)
검색
검색
보이기
계정 만들기
로그인
개인 도구
계정 만들기
로그인
미디어위키:Gadget-MetadataEditor.js 문서 원본 보기
메시지
토론
English
읽기
원본 보기
역사 보기
도구
도구
사이드바로 이동
숨기기
동작
읽기
원본 보기
역사 보기
새로 고침
일반
여기를 가리키는 문서
가리키는 글의 최근 바뀜
특수 문서 목록
문서 정보
축약된 URL 얻기
보이기
사이드바로 이동
숨기기
←
미디어위키:Gadget-MetadataEditor.js
문서 편집 권한이 없습니다. 다음 이유를 확인해주세요:
요청한 명령은 다음 권한을 가진 사용자에게 제한됩니다:
사용자
.
이 문서는 소프트웨어 인터페이스에 쓰이는 문서로, 부정 행위를 막기 위해 보호되어 있습니다.
이 문서는
관리자
만이 수정할 수 있습니다. 내용의 변경이 필요하다면
관리자 요청
에 편집 요청을 남겨 주세요.
모든 방문자에게 영향을 미칠 수 있기 때문에 이 자바스크립트 문서의 편집 권한이 없습니다.
문서의 원본을 보거나 복사할 수 있습니다.
var metadata_schema; var jsonEditorContainer; var metadata_editorvalue; let editor; const saveToDocument = (ev) => { const jsonValue = editor.getValue(); if (!jsonValue) { mw.notify("메타데이터를 저장할 수 없습니다.", {type: "error"}); return; } else if (editor.validate().length) { console.log(editor.getValue()); mw.notify("메타데이터가 적절한지 확인하는 데에 실패했습니다.", {type: "error"}); return; } const api = new mw.Api(); api.postWithEditToken( { "action": "edit", "title": mw.config.get( "wgPageName" ) + "/game.json", "text": JSON.stringify(jsonValue), "summary": "메타데이터 수정", "contentmodel": "json" } ).then((result) =>{ mw.notify("메타데이터를 저장했습니다!", {type: "success"}); }).catch((error, result) => { mw.notify("메타데이터 저장 실패!" + error + " -> " + JSON.stringify(result), {type: "error"}); }); }; const addMetadataTab = (resultPromise) => { resultPromise.then((result) => { metadata_schema = result; metadata_editorvalue = document.querySelector('#value'); JSONEditor.defaults.languages.ko = TRANSLATION; JSONEditor.defaults.language = "ko"; // 탭 추가 let metadataTab = mw.util.addPortletLink("p-associated-pages", "#", "메타데이터 편집", "metadata-edittab", "메타데이터를 편집합니다"); metadataTab.addEventListener('click', (ev) => { var targetJSON = `https://dev.libertygame.work/index.php/${mw.config.get("wgPageName")}/game.json?action=raw`; fetch(targetJSON).then(function(result){return result.json(); }).then(function (response) { document.getElementById("jsoneditor-container").style.display = "block"; editor = new JSONEditor(jsonEditorContainer, { mode: 'tree', schema: metadata_schema, theme: 'tailwind', iconlib: 'openiconic', keep_oneof_values: false, disable_edit_json: true, disable_collapse : true, array_controls_top : true, startval:response }); }).catch((e) => {console.log('JSON 에디터 로딩 후 JSON 타겟 가져오기 실패')}); }); // 메타데이터 편집기 추가 let metadataEditor = document.createElement("div"); metadataEditor.id = "jsoneditor-container"; metadataEditor.style.display = "none"; metadataEditor.style['background-color'] = "#bbeebb"; metadataEditor.style.position= "fixed"; metadataEditor.style["z-index"] = 8; metadataEditor.style.top = "80px"; document.getElementById("bodyContent").appendChild(metadataEditor); jsonEditorContainer = metadataEditor; let metadataCloseButton = document.createElement("button"); metadataCloseButton.onclick = (ev) => {ev.target.parentElement.style.display = "none";}; metadataCloseButton.innerText = "편집기 닫기"; metadataEditor.appendChild(metadataCloseButton); let metadataSaveButton = document.createElement("button"); metadataSaveButton.onclick = saveToDocument; metadataSaveButton.innerText = "저장하기"; metadataEditor.appendChild(metadataSaveButton); }); }; const addJSONEditor = () => { const title = mw.config.get("wgPageName"); const api = new mw.Api(); Promise.all([ api.getCategories(title), mw.loader.getScript("https://cdn.jsdelivr.net/npm/@json-editor/json-editor@latest/dist/jsoneditor.min.js"), fetch("https://dev.libertygame.work/index.php/%EB%A6%AC%EB%B2%84%ED%8B%B0%EA%B2%8C%EC%9E%84:%EA%B2%8C%EC%9E%84_%EB%A9%94%ED%83%80%EB%8D%B0%EC%9D%B4%ED%84%B0/%EC%8A%A4%ED%82%A4%EB%A7%88.json?action=raw") ]).then((values) =>{ if (!values[0]) return; let esc = true; for (const category of values[0]){ if (category.title === "리버티게임"){ esc = false; } } if (esc) return; addMetadataTab(values[2].json()); }).catch((e) => {console.log('메타데이터 편집기 로딩 실패')});; }; // 호이스팅으로 끌어올려지는 상수 정의 var TRANSLATION = { button_add: "추가", button_add_row_title: "{{0}} 추가", button_cancel: "취소", button_collapse: "숨기기", button_copy: "복사", button_copy_row_title: "{{0}} 복사", button_copy_row_title_short: "복사", button_delete_all: "전부 삭제", button_delete_all_title: "전부 삭제", button_delete_last: "마지막 {{0}} 삭제", button_delete_last_title: "마지막 {{0}} 삭제", button_delete_node_warning: "정말 이 아이템을 제거하시겠습니까?", button_delete_row_title: "{{0}} 삭제", button_delete_row_title_short: "삭제", button_edit_json: "JSON 편집", button_expand: "확장", button_move_down_title: "아래로 내리기", button_move_up_title: "위로 올리기", button_object_properties: "오브젝트 속성", button_properties: "속성 목록", button_save: "저장", button_upload: "올리기", choices_placeholder_text: "값을 추가하기 위해 입력하세요", default_array_item_title: "아이템", error_additionalItems: "더 이상 배열에 원소를 넣을 수 없습니다!", error_additional_properties: "더 이상 프로퍼티를 추가할 수 없는데도 {{0}} 추가됨", error_anyOf: "제공된 스키마 중 하나에 값이 맞아야 합니다.", error_const: "값은 상수여야 합니다", error_contains: "contains에 맞지 않는 문자열입니다.", error_date: "잘못된 시간입니다: {{0}}", error_datetime_local: "잘못된 형식의 시간입니다: {{0}}", error_dependency: "{{0}} 프로퍼티가 있어야 합니다.", error_disallow: "{{0}} 종류의 값이 될 수 없습니다", error_disallow_union: "이 값은 허용되지 않은 종류의 값입니다.", error_enum: "순차값 중 하나로 입력해야 합니다.", error_hostname:"호스트 이름이 잘못되었습니다", error_invalid_epoch: "1970년 1월 1일보다 나중으로 입력해주세요", error_ipv4: "Value must be a valid IPv4 address in the form of 4 numbers between 0 and 255, separated by dots", error_ipv6: "Value must be a valid IPv6 address", error_maxContains: "Contains match count {{0}} exceeds maximum contains count of {{1}}", error_maxItems: "Value must have at most {{0}} items", error_maxLength: "Value must be at most {{0}} characters long", error_maxProperties: "Object must have at most {{0}} properties", error_maximum_excl: "Value must be less than {{0}}", error_maximum_incl: "Value must be at most {{0}}", error_minContains: "Contains match count {{0}} is less than minimum contains count of {{1}}", error_minItems: "Value must have at least {{0}} items", error_minLength: "Value must be at least {{0}} characters long", error_minProperties: "Object must have at least {{0}} properties", error_minimum_excl: "Value must be greater than {{0}}", error_minimum_incl: "Value must be at least {{0}}", error_multipleOf: "Value must be a multiple of {{0}}", error_not: "Value must not validate against the provided schema", error_notempty: "값이 없습니다", error_notset:"프로퍼티가 주어지지 않았습니다", error_oneOf: "Value must validate against exactly one of the provided schemas. It currently validates against {{0}} of the schemas.", error_pattern: "Value must match the pattern {{0}}", error_property_names_const_mismatch: "Property name {{0}} does not match the const value", error_property_names_enum: "Property name {{0}} cannot match invalid enum", error_property_names_enum_mismatch: "Property name {{0}} does not match any enum values", error_property_names_exceeds_maxlength: "Property name {{0}} exceeds maxLength", error_property_names_false: "Property name {{0}} fails when propertyName is false", error_property_names_maxlength: "Property name {{0}} cannot match invalid maxLength", error_property_names_pattern: "Property name {{0}} cannot match invalid pattern", error_property_names_pattern_mismatch: "Property name {{0}} does not match pattern", error_property_names_unsupported: "지원되지 않는 프로퍼티 이름 {{0}}", error_required: "오브젝트에 반드시 필요한 프로퍼티가 없습니다: '{{0}}'", error_time: "Time must be in the format {{0}}", error_type: "Value must be of type {{0}}", error_type_union: "주어진 종류의 값 중 하나를 가져야 합니다.", error_uniqueItems: "배열의 원소는 각기 다른 값을 가져야 합니다.", flatpickr_clear_button: "전부 삭제", flatpickr_toggle_button: "열고 닫기", paste_max_length_reached: "Pasted text exceeded maximum length of {{0}} and will be clipped.", table_controls: "컨트롤", upload_max_size: "파일 크기가 너무 큽니다. 최대 허용치는 ", upload_wrong_file_format: "파일 포맷이 잘못되었습니다. 사용 가능한 포맷: " }; $(addJSONEditor);
미디어위키:Gadget-MetadataEditor.js
문서로 돌아갑니다.