|
@@ -126,43 +126,37 @@ function writeMd() {
|
|
|
var imagefile = document.querySelector("#cfile");
|
|
|
|
|
|
if ($("#ctype").val() == "collection") {
|
|
|
- var offset1=0; //in case we dont have complete images, we have to offset
|
|
|
- var offset2=0;
|
|
|
- var offset3=0;
|
|
|
+ var offset1 = 0; //in case we dont have complete images, we have to offset
|
|
|
+ var offset2 = 0;
|
|
|
+ var offset3 = 0;
|
|
|
var imagefil2 = document.querySelector("#cnewcoverimg");
|
|
|
var imagefil3 = document.querySelector("#cnewcomment");
|
|
|
var imagefil4 = document.querySelector("#cnewownerimg");
|
|
|
var imgcount = 1;
|
|
|
|
|
|
console.log($("#cfile").val());
|
|
|
- if($("#cfile").val() == "" || $("#cfile").val() == undefined)
|
|
|
- {
|
|
|
- offset1=1;
|
|
|
+ if ($("#cfile").val() == "" || $("#cfile").val() == undefined) {
|
|
|
+ offset1 = 1;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
formData.append("image" + imgcount.toString(), imagefile.files[0]);
|
|
|
imgcount++;
|
|
|
}
|
|
|
|
|
|
console.log($("#cnewcoverimg").val());
|
|
|
- if ($("#cnewcoverimg").val() == "" || $("#cnewcoverimg").val() == undefined)
|
|
|
- {
|
|
|
- offset2=1;
|
|
|
+ if ($("#cnewcoverimg").val() == "" || $("#cnewcoverimg").val() == undefined) {
|
|
|
+ offset2 = 1;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
formData.append("image" + imgcount.toString(), imagefil2.files[0]);
|
|
|
imgcount++;
|
|
|
}
|
|
|
|
|
|
console.log($("#cnewcomment").val());
|
|
|
- if ($("#cnewcomment").val() == "" || $("#cnewcomment").val() == undefined)
|
|
|
- {
|
|
|
- offset3=1;
|
|
|
+ if ($("#cnewcomment").val() == "" || $("#cnewcomment").val() == undefined) {
|
|
|
+ offset3 = 1;
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
formData.append("image" + imgcount.toString(), imagefil3.files[0]);
|
|
|
imgcount++;
|
|
|
}
|
|
@@ -185,53 +179,45 @@ function writeMd() {
|
|
|
if (data.success == "1") {
|
|
|
console.log(data.fileurl);
|
|
|
var imglinks = data.fileurl.split(";;;");
|
|
|
- if($("#cfile").val() == "" || $("#cfile").val() == undefined)
|
|
|
- {
|
|
|
+ if ($("#cfile").val() == "" || $("#cfile").val() == undefined) {
|
|
|
//do nothing
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
alert("Replacing header image");
|
|
|
mdContent = mdContent.replace(
|
|
|
$("#cfile").val(),
|
|
|
"/img/title/" + imglinks[0]
|
|
|
);
|
|
|
}
|
|
|
- if($("#cnewcoverimg").val() == "" || $("#cnewcoverimg").val() == undefined)
|
|
|
- {
|
|
|
+ if ($("#cnewcoverimg").val() == "" || $("#cnewcoverimg").val() == undefined) {
|
|
|
//do nothing
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
alert("Replacing cover image");
|
|
|
mdContent = mdContent.replace(
|
|
|
$("#cnewcoverimg").val(),
|
|
|
- "/img/title/" + imglinks[1-offset1]
|
|
|
+ "/img/title/" + imglinks[1 - offset1]
|
|
|
);
|
|
|
}
|
|
|
- if($("#cnewcomment").val() == "" || $("#cnewcomment").val() == undefined)
|
|
|
- {
|
|
|
+ if ($("#cnewcomment").val() == "" || $("#cnewcomment").val() == undefined) {
|
|
|
//do nothing
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
alert("Replacing comment image");
|
|
|
mdContent = mdContent.replace(
|
|
|
$("#cnewcomment").val(),
|
|
|
- "/img/title/" + imglinks[2-offset1-offset2]
|
|
|
+ "/img/title/" + imglinks[2 - offset1 - offset2]
|
|
|
);
|
|
|
}
|
|
|
- if($("#cnewownerimg").val() == "" || $("#cnewownerimg").val() == undefined)
|
|
|
- {
|
|
|
+ if ($("#cnewownerimg").val() == "" || $("#cnewownerimg").val() == undefined) {
|
|
|
//do nothing
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
+ else {
|
|
|
alert("Replacing owner image");
|
|
|
- mdContent = mdContent.replace(
|
|
|
- $("#cnewownerimg").val(),
|
|
|
- "/img/title/" + imglinks[3-offset1-offset2-offset3]
|
|
|
- );
|
|
|
+ mdContent = mdContent.replace(
|
|
|
+ $("#cnewownerimg").val(),
|
|
|
+ "/img/title/" + imglinks[3 - offset1 - offset2 - offset3]
|
|
|
+ );
|
|
|
}
|
|
|
} else {
|
|
|
console.log("skipped");
|
|
@@ -244,7 +230,7 @@ function writeMd() {
|
|
|
|
|
|
axios
|
|
|
.post(contentApiUrl + editTarget, (json = postData))
|
|
|
- .then(({ data }) => {});
|
|
|
+ .then(({ data }) => { });
|
|
|
})
|
|
|
.finally(() => {
|
|
|
alert("資料已更新"); // test
|
|
@@ -263,7 +249,7 @@ function writeMd() {
|
|
|
mdContent = mdContent.replace(
|
|
|
$("#cfile").val(),
|
|
|
"/img/title/" +
|
|
|
- data.file.url.substring(data.file.url.lastIndexOf("/") + 1)
|
|
|
+ data.file.url.substring(data.file.url.lastIndexOf("/") + 1)
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -273,7 +259,7 @@ function writeMd() {
|
|
|
};
|
|
|
axios
|
|
|
.post(contentApiUrl + editTarget, (json = postData))
|
|
|
- .then(({ data }) => {});
|
|
|
+ .then(({ data }) => { });
|
|
|
})
|
|
|
.finally(() => {
|
|
|
alert("資料已更新"); // test
|
|
@@ -825,20 +811,20 @@ function ParseProductSection(inContent) {
|
|
|
tmpsrc = ampimg.substr(
|
|
|
ampimg.indexOf('src="') + 5,
|
|
|
ampimg.indexOf('"', ampimg.indexOf('src="') + 5) -
|
|
|
- ampimg.indexOf('src="') -
|
|
|
- 5
|
|
|
+ ampimg.indexOf('src="') -
|
|
|
+ 5
|
|
|
);
|
|
|
tmpw = ampimg.substr(
|
|
|
ampimg.indexOf('width="') + 7,
|
|
|
ampimg.indexOf('"', ampimg.indexOf('width="') + 7) -
|
|
|
- ampimg.indexOf('width="') -
|
|
|
- 7
|
|
|
+ ampimg.indexOf('width="') -
|
|
|
+ 7
|
|
|
);
|
|
|
tmph = ampimg.substr(
|
|
|
ampimg.indexOf('height="') + 8,
|
|
|
ampimg.indexOf('"', ampimg.indexOf('height="') + 8) -
|
|
|
- ampimg.indexOf('height="') -
|
|
|
- 8
|
|
|
+ ampimg.indexOf('height="') -
|
|
|
+ 8
|
|
|
);
|
|
|
//tmph = ampimg.substr(ampimg.indexOf("width=\"") + 7, ampimg.indexOf("\"", ampimg.indexOf("width=\"") + 7) - ampimg.indexOf("width=\"") - 7);
|
|
|
editorBlocks.push({
|
|
@@ -853,7 +839,7 @@ function ParseProductSection(inContent) {
|
|
|
},
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
// for (i = 0; i < imgnodes.length; i++) {
|
|
@@ -1009,8 +995,8 @@ function ParseProductSection(inContent) {
|
|
|
}
|
|
|
|
|
|
//處理規格圖片
|
|
|
- if ($("[class='b-bottom pb-3 mb-5 spec']", aa).length > 0) {
|
|
|
- snodes = $("[class='b-bottom pb-3 mb-5 spec']", aa)[0].childNodes;
|
|
|
+ if ($("[class='spec']", aa).length > 0) {
|
|
|
+ snodes = $("[class='spec']", aa)[0].childNodes;
|
|
|
console.log(snodes);
|
|
|
//alert(snodes[0].innerHTML);
|
|
|
for (i = 0; i < snodes.length; i++) {
|
|
@@ -1020,20 +1006,20 @@ function ParseProductSection(inContent) {
|
|
|
tmpsrc = ampimg.substr(
|
|
|
ampimg.indexOf('src="') + 5,
|
|
|
ampimg.indexOf('"', ampimg.indexOf('src="') + 5) -
|
|
|
- ampimg.indexOf('src="') -
|
|
|
- 5
|
|
|
+ ampimg.indexOf('src="') -
|
|
|
+ 5
|
|
|
);
|
|
|
tmpw = ampimg.substr(
|
|
|
ampimg.indexOf('width="') + 7,
|
|
|
ampimg.indexOf('"', ampimg.indexOf('width="') + 7) -
|
|
|
- ampimg.indexOf('width="') -
|
|
|
- 7
|
|
|
+ ampimg.indexOf('width="') -
|
|
|
+ 7
|
|
|
);
|
|
|
tmph = ampimg.substr(
|
|
|
ampimg.indexOf('height="') + 8,
|
|
|
ampimg.indexOf('"', ampimg.indexOf('height="') + 8) -
|
|
|
- ampimg.indexOf('height="') -
|
|
|
- 8
|
|
|
+ ampimg.indexOf('height="') -
|
|
|
+ 8
|
|
|
);
|
|
|
//tmph = ampimg.substr(ampimg.indexOf("width=\"") + 7, ampimg.indexOf("\"", ampimg.indexOf("width=\"") + 7) - ampimg.indexOf("width=\"") - 7);
|
|
|
editorBlocks1.push({
|
|
@@ -1125,7 +1111,8 @@ function GenProductSection(mimg, specimg) {
|
|
|
<li>1. 商品顏色因拍攝、螢幕差異略有不同,實際顏色請依照門市實際顏色為主。</li>
|
|
|
<li>2. 部分商品因應空間大小,保有客製尺寸服務。詳細尺寸資訊,請預約門市諮詢訂購。</li>
|
|
|
</ul>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ <div class="b-bottom mt-5"></div>
|
|
|
<div class="mb-5">
|
|
|
<a href="/furniture_design/other_furniture/">
|
|
|
<p class="readMore text-center">
|
|
@@ -1150,45 +1137,45 @@ function GenProductSection(mimg, specimg) {
|
|
|
tmpstr = tmpstr.replaceAll(
|
|
|
"##swfPrice##",
|
|
|
"<div class='me-3 my-2 d-flex'><div class='tw-15'>定價</div>" +
|
|
|
- "<div class='pdprice tw-85'>" +
|
|
|
- $("#swfPrice").val() +
|
|
|
- "</div></div>"
|
|
|
+ "<div class='pdprice tw-85'>" +
|
|
|
+ $("#swfPrice").val() +
|
|
|
+ "</div></div>"
|
|
|
);
|
|
|
else tmpstr = tmpstr.replaceAll("##swfPrice##", "<span></span>");
|
|
|
if ($("#swfColor").val() != "")
|
|
|
tmpstr = tmpstr.replaceAll(
|
|
|
"##swfColor##",
|
|
|
"<div class='my-2 d-flex'><div class='tw-15'>顏色</div>" +
|
|
|
- "<div class='pdcolor tw-85'>" +
|
|
|
- $("#swfColor").val() +
|
|
|
- "</div></div>"
|
|
|
+ "<div class='pdcolor tw-85'>" +
|
|
|
+ $("#swfColor").val() +
|
|
|
+ "</div></div>"
|
|
|
);
|
|
|
else tmpstr = tmpstr.replaceAll("##swfColor##", "<span></span>");
|
|
|
if ($("#swfSize").val() != "")
|
|
|
tmpstr = tmpstr.replaceAll(
|
|
|
"##swfSize##",
|
|
|
"<div class='my-2 d-flex'><div class='tw-15'>尺寸</div>" +
|
|
|
- "<div class='pdsize tw-85'>" +
|
|
|
- $("#swfSize").val() +
|
|
|
- "</div></div>"
|
|
|
+ "<div class='pdsize tw-85'>" +
|
|
|
+ $("#swfSize").val() +
|
|
|
+ "</div></div>"
|
|
|
);
|
|
|
else tmpstr = tmpstr.replaceAll("##swfSize##", "<span></span>");
|
|
|
if ($("#swfMat").val() != "")
|
|
|
tmpstr = tmpstr.replaceAll(
|
|
|
"##swfMat##",
|
|
|
"<div class='my-2 d-flex'><div class='tw-15'>材質</div>" +
|
|
|
- "<div class='pmat tw-85'>" +
|
|
|
- $("#swfMat").val() +
|
|
|
- "</div></div>"
|
|
|
+ "<div class='pmat tw-85'>" +
|
|
|
+ $("#swfMat").val() +
|
|
|
+ "</div></div>"
|
|
|
);
|
|
|
else tmpstr = tmpstr.replaceAll("##swfMat##", "<span></span>");
|
|
|
if ($("#swfMemo").val() != "")
|
|
|
tmpstr = tmpstr.replaceAll(
|
|
|
"##swfMemo##",
|
|
|
"<div class='my-2 d-flex'><div class='tw-15'>備註</div> " +
|
|
|
- "<div class='pdmark tw-85'>" +
|
|
|
- $("#swfMemo").val() +
|
|
|
- "</div></div>"
|
|
|
+ "<div class='pdmark tw-85'>" +
|
|
|
+ $("#swfMemo").val() +
|
|
|
+ "</div></div>"
|
|
|
);
|
|
|
else tmpstr = tmpstr.replaceAll("##swfMemo##", "<span></span>");
|
|
|
|
|
@@ -1251,14 +1238,16 @@ function GenProductSection(mimg, specimg) {
|
|
|
);
|
|
|
|
|
|
specimgstr = "";
|
|
|
+
|
|
|
for (i = 0; i < specimg.blocks.length; i++) {
|
|
|
//alert(block.type);
|
|
|
block = specimg.blocks[i];
|
|
|
+ console.log(block);
|
|
|
if (block.type == "image") {
|
|
|
iurl = block.data.file.url.split("/");
|
|
|
if (iurl[iurl.length - 1] != "logo2.png") {
|
|
|
specimgstr +=
|
|
|
- '<img\n class="w-100 h-100" alt="小寶優居 | ' +
|
|
|
+ '<h6>尺寸規格</h6><img\n class="w-100 h-100" alt="小寶優居 | ' +
|
|
|
$("#ctitle").val() +
|
|
|
'"\n src="img/' +
|
|
|
iurl[iurl.length - 1] +
|
|
@@ -1266,15 +1255,23 @@ function GenProductSection(mimg, specimg) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(specimgstr===""){
|
|
|
+ specimgstr+='<div></div>'
|
|
|
+ }
|
|
|
+
|
|
|
tmpstr = tmpstr.replaceAll(
|
|
|
"##SPEC-IMG##",
|
|
|
specimgstr == ""
|
|
|
? ""
|
|
|
- : '<div class="b-bottom pb-3 mb-5 spec"><h6>尺寸規格</h6>' +
|
|
|
- specimgstr +
|
|
|
- "</div>"
|
|
|
+ : '<div class="spec">' +
|
|
|
+ specimgstr +
|
|
|
+ "</div>"
|
|
|
+
|
|
|
);
|
|
|
|
|
|
+
|
|
|
+ console.log(tmpstr)
|
|
|
+
|
|
|
return tmpstr;
|
|
|
}
|
|
|
|