Skip to content

Commit

Permalink
Remove Kanpen export support
Browse files Browse the repository at this point in the history
  • Loading branch information
x-sheep committed Dec 31, 2024
1 parent 7ebe972 commit 3e75989
Show file tree
Hide file tree
Showing 32 changed files with 11 additions and 613 deletions.
25 changes: 1 addition & 24 deletions src-ui/js/ui/PopupMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,17 +487,9 @@ ui.popupmgr.addpopup("urloutput", {
},

reset: function(px, py) {
var form = this.form,
pid = ui.puzzle.pid,
exists = pzpr.variety(pid).exists,
parser = pzpr.parser;
var parser = pzpr.parser;
var url = ui.puzzle.getURL(parser.URL_PZPRV3);
this.urlanchor.href = this.urlanchor.textContent = url;
form.kanpen.style.display = form.kanpen.nextSibling.style.display = exists.kanpen
? ""
: "none";
form.heyaapp.style.display = form.heyaapp.nextSibling.style.display =
pid === "heyawake" ? "" : "none";
},

show: function(px, py) {
Expand All @@ -513,17 +505,11 @@ ui.popupmgr.addpopup("urloutput", {
var url = "",
parser = pzpr.parser;
switch (e.target.name) {
case "kanpen":
url = ui.puzzle.getURL(parser.URL_KANPEN);
break;
case "pzprv3e":
url = ui.puzzle
.getURL(parser.URL_PZPRV3)
.replace(/\?(\w+)/, "?$1_edit");
break;
case "heyaapp":
url = ui.puzzle.getURL(parser.URL_HEYAAPP);
break;
}
this.urlanchor.href = this.urlanchor.textContent = url;
}
Expand Down Expand Up @@ -577,9 +563,6 @@ ui.popupmgr.addpopup("filesave", {
},
reset: function() {
/* ファイル形式選択オプション */
var ispencilbox = pzpr.variety(ui.puzzle.pid).exists.pencilbox;
this.form.filetype.options[1].disabled = !ispencilbox;
this.form.filetype.options[2].disabled = !ispencilbox;
var parser = pzpr.parser;
this.form.ta.value = ui.puzzle.getFileData(parser.FILE_PZPR, {});
this.form.ta2.value = this.form.ta.value.replace(/\n/g, "/");
Expand Down Expand Up @@ -637,12 +620,6 @@ ui.popupmgr.addpopup("filesave", {
filetype = parser.FILE_PZPR,
option = {};
switch (form.filetype.value) {
case "filesave2":
filetype = parser.FILE_PBOX;
break;
case "filesave4":
filetype = parser.FILE_PBOX_XML;
break;
case "filesave3":
filetype = parser.FILE_PZPR;
option.history = true;
Expand Down
4 changes: 0 additions & 4 deletions src-ui/p.html
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,6 @@ <h2 id="title2">読み込み中です...</h2>
<form name="urloutput">
<a id="urlanchor" class="urlanchor" target="_blank"></a>
<br>
<button type="button" class="btn" data-button-exec="urloutput" name="kanpen" >__urloutput.kanpen__</button><br>
<button type="button" class="btn" data-button-exec="urloutput" name="heyaapp">__urloutput.heyaapp__</button><br>
<button type="button" class="btn" data-button-exec="urloutput" name="pzprv3e">__urloutput.pzprv3e__</button><br>
<br>
<button type="button" class="btn" data-button-exec="close">__close__</button>
Expand Down Expand Up @@ -603,8 +601,6 @@ <h2 id="title2">読み込み中です...</h2>
<span>__filesave.format__</span>
<select name="filetype" data-change-exec="changefilename">
<option value="filesave">__filesave.format.pzprv3__</option>
<option value="filesave2">__filesave.format.penciltxt__</option>
<option value="filesave4">__filesave.format.pencilxml__</option>
</select>
<br>
<span>__filesave.filename__</span>
Expand Down
4 changes: 0 additions & 4 deletions src-ui/res/p.en.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,16 +241,12 @@
"urlinput.title": "Load from URL",
"urlinput.submit": "Load",
"urloutput.title": "Export URL",
"urloutput.kanpen": "Change to Kanpen URL",
"urloutput.heyaapp": "Change to Heyawake-Applet URL",
"urloutput.pzprv3e": "Change to PUZ-PRE v3 Re-Edit URL",
"fileopen.title": "Open File",
"fileopen.choose": "Choose file",
"filesave.title": "Save File",
"filesave.format": "File format",
"filesave.format.pzprv3": "Puz-Pre v3 format",
"filesave.format.penciltxt": "Pencilbox Text format",
"filesave.format.pencilxml": "Pencilbox XML format",
"filesave.filename": "Filename",
"filesave.submit": "Save",
"filesave.invalid": "The filename contains invalid characters.",
Expand Down
4 changes: 0 additions & 4 deletions src-ui/res/p.ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,12 @@
"urlinput.title": "URL入力",
"urlinput.submit": "読み込む",
"urloutput.title": "URL出力",
"urloutput.kanpen": "カンペンのURLを出力する",
"urloutput.heyaapp": "へやわけアプレットのURLを出力する",
"urloutput.pzprv3e": "ぱずぷれv3の再編集用URLを出力する",
"fileopen.title": "ファイルを開く",
"fileopen.choose": "ファイル選択",
"filesave.title": "ファイルを保存する",
"filesave.format": "ファイル形式",
"filesave.format.pzprv3": "ファイル形式",
"filesave.format.penciltxt": "pencilbox形式",
"filesave.format.pencilxml": "pencilbox XML形式",
"filesave.filename": "ファイル名",
"filesave.submit": "保存",
"filesave.invalid": "ファイル名として使用できない文字が含まれています。",
Expand Down
36 changes: 1 addition & 35 deletions src/puzzle/Encode.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ pzpr.classmgr.makeCommon({
bd = puzzle.board;
var pzl = new pzpr.parser.URLData("", mode);

type =
type || pzl.URL_PZPRV3; /* type===pzl.URL_AUTO(0)もまとめて変換する */
if (type === pzl.URL_KANPEN && pid === "lits") {
type = pzl.URL_KANPENP;
}
type = type || pzl.URL_PZPRV3;

this.outpflag = null;
var variant = puzzle.getConfig("variant");
Expand All @@ -109,30 +105,6 @@ pzpr.classmgr.makeCommon({
this.outbstr = lines.join("/");
break;

case pzl.URL_PZPRAPP:
throw Error("no implementation");

case pzl.URL_KANPENP:
if (!puzzle.info.exists.kanpen) {
throw Error("no implementation");
}
this.encodePzpr(pzl.URL_PZPRAPP);
this.outpflag = this.outpflag || "";
break;

case pzl.URL_KANPEN:
this.fio = new puzzle.klass.FileIO();
this.encodeKanpen();
this.outbstr = this.fio.datastr
.replace(/\r?\n/g, "/")
.replace(/ /g, "_");
this.fio = null;
break;

case pzl.URL_HEYAAPP:
this.encodeHeyaApp();
break;

default:
throw Error("invalid URL Type");
}
Expand All @@ -158,14 +130,8 @@ pzpr.classmgr.makeCommon({
decodeKanpen: function() {
throw Error("no implementation");
},
encodeKanpen: function() {
throw Error("no implementation");
},
decodeHeyaApp: function() {
throw Error("no implementation");
},
encodeHeyaApp: function() {
throw Error("no implementation");
}
}
});
25 changes: 1 addition & 24 deletions src/puzzle/FileData.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,6 @@

this.filever = 0;
this.datastr = "";
if (filetype === pzl.FILE_PBOX_XML) {
this.xmldoc = new DOMParser().parseFromString(
'<?xml version="1.0" encoding="utf-8" ?><puzzle />',
"text/xml"
);
var puzzlenode = this.xmldoc.querySelector("puzzle");
puzzlenode.appendChild(this.createXMLNode("board"));
puzzlenode.appendChild(this.createXMLNode("answer"));
}

// メイン処理
switch (filetype) {
Expand All @@ -104,14 +95,6 @@
}
break;

case pzl.FILE_PBOX:
this.kanpenSave();
break;

case pzl.FILE_PBOX_XML:
this.kanpenSaveXML();
break;

default:
throw Error("invalid filetype");
}
Expand All @@ -120,11 +103,7 @@
pzl.filever = this.filever;
pzl.cols = bd.cols;
pzl.rows = bd.rows;
if (filetype !== pzl.FILE_PBOX_XML) {
pzl.body = this.datastr;
} else {
pzl.body = this.xmldoc;
}
pzl.body = this.datastr;
pzl.metadata.update(puzzle.metadata);
if (option.history && filetype === pzl.FILE_PZPR) {
pzl.history = puzzle.opemgr.encodeHistory({ time: !!option.time });
Expand All @@ -139,9 +118,7 @@
decodeData: throwNoImplementation,
encodeData: throwNoImplementation,
kanpenOpen: throwNoImplementation,
kanpenSave: throwNoImplementation,
kanpenOpenXML: throwNoImplementation,
kanpenSaveXML: throwNoImplementation,

//---------------------------------------------------------------------------
// fio.decodeTrial() 仮置きデータを復旧する
Expand Down
50 changes: 8 additions & 42 deletions src/pzpr/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,6 @@
case URL_PZPRV3:
url = url + "?%PID%/";
break;
case URL_KANPEN:
url = "http://www.kanpen.net/%KID%.html?problem=";
break;
case URL_KANPENP:
url = "http://www.kanpen.net/%KID%.html?pzpr=";
break;
case URL_HEYAAPP:
url = "http://www.geocities.co.jp/heyawake/?problem=";
break;
case URL_PZPRFILE:
url = url + "?";
break;
Expand All @@ -253,9 +244,7 @@
if (this.type === URL_PZPRFILE) {
url = url + typ;
}
return url
.replace("%PID%", pzpr.variety(pid).urlid)
.replace("%KID%", pzpr.variety(this.pid).kanpenid);
return url.replace("%PID%", pzpr.variety(pid).urlid);
},

//---------------------------------------------------------------------------
Expand Down Expand Up @@ -329,29 +318,15 @@
out = [];

/* URLにつけるオプション */
if (pzl.type !== URL_KANPEN && pzl.type !== URL_HEYAAPP) {
if (pzl.variant !== null) {
out.push("v:" + pzl.variant);
}
if (pzl.type === URL_KANPENP || !!pzl.pflag) {
out.push(pzl.pflag);
}
if (pzl.variant !== null) {
out.push("v:" + pzl.variant);
}
if (!!pzl.pflag) {
out.push(pzl.pflag);
}

/* サイズを表す文字列 */
if (pzl.type === URL_KANPEN) {
if (pzl.pid === "kakuro") {
out.push(row + 1);
out.push(col + 1);
} else if (pzl.pid === "sudoku") {
out.push(col);
} else {
out.push(row);
out.push(col);
}
} else if (pzl.type === URL_HEYAAPP) {
out.push([col, row].join("x"));
} else if (pzl.type !== URL_PZPRFILE) {
if (pzl.type !== URL_PZPRFILE) {
out.push(col);
out.push(row);
}
Expand Down Expand Up @@ -731,16 +706,7 @@
puzzlenode.appendChild(puzzlenode.querySelector("answer"));
}

var outputdata;
if (pzl.type !== FILE_PBOX_XML) {
outputdata = out.join("\n");
} else {
outputdata = new XMLSerializer().serializeToString(this.body);
if (!outputdata.match(/^\<\?xml/)) {
outputdata = '<?xml version="1.0" encoding="UTF-8"?>\n' + outputdata;
}
}
return outputdata;
return out.join("\n");
},

createXMLNode: function(name, attrs) {
Expand Down
Loading

0 comments on commit 3e75989

Please sign in to comment.