Commit a421d64f authored by minseok.park's avatar minseok.park

test download

parent cac1a80a
Pipeline #21711 passed with stages
in 4 minutes and 17 seconds
......@@ -2,7 +2,7 @@
'use strict'
var download = document.getElementById('download')
const downlaodMobile = document.getElementById('mobile-download')
const downloadMobile = document.getElementById('mobile-download')
document.addEventListener('scroll', function () {
var navbar = document.querySelector('.navbar')
......@@ -14,37 +14,65 @@
}
})
download.addEventListener('click', function () {
function downloadFile () {
var pathname = window.location.pathname
var path = pathname.split('/')
var isInternal = path[4].includes('-s')
var filename = path[3] ? path[3] === 'swlab-docs'
? 'docs' : isInternal ? `docs-${path[3]}-s` : `docs-${path[3]}` : ''
var directory = path[3] && path[4] ? path[3] === 'swlab-docs' ? path[3] : path[4] : ''
var link = document.createElement('a')
var isInternal = path[4]?.includes('-s')
var filename = path[3]
? path[3] === 'swlab-docs'
? 'docs'
: isInternal
? `docs-${path[3]}-s`
: `docs-${path[3]}`
: ''
var directory = path[3] && path[4]
? path[3] === 'swlab-docs'
? path[3]
: path[4]
: ''
link.href = `https://swlab.bwg.co.kr/web/dms/download-file?filename=${filename}.zip&directory=${directory}`
link.click()
// 링크 생성 및 열기
var link = `https://swlab.bwg.co.kr/web/dms/download-file?filename=${filename}.zip&directory=${directory}`
window.open(link, '_blank')
}
if (link.parentNode) {
document.body.removeChild(link)
}
})
// PC 다운로드 버튼
download.addEventListener('click', downloadFile)
downlaodMobile.addEventListener('click', function () {
var pathname = window.location.pathname
var path = pathname.split('/')
var isInternal = path[4].includes('-s')
var filename = path[3] ? path[3] === 'swlab-docs'
? 'docs' : isInternal ? `docs-${path[3]}-s` : `docs-${path[3]}` : ''
var directory = path[3] && path[4] ? path[3] === 'swlab-docs' ? path[3] : path[4] : ''
var link = document.createElement('a')
// 모바일 다운로드 버튼
downloadMobile.addEventListener('click', downloadFile)
link.href = `https://swlab.bwg.co.kr/web/dms/download-file?filename=${filename}.zip&directory=${directory}`
link.click()
// download.addEventListener('click', function () {
// var pathname = window.location.pathname
// var path = pathname.split('/')
// var isInternal = path[4].includes('-s')
// var filename = path[3] ? path[3] === 'swlab-docs'
// ? 'docs' : isInternal ? `docs-${path[3]}-s` : `docs-${path[3]}` : ''
// var directory = path[3] && path[4] ? path[3] === 'swlab-docs' ? path[3] : path[4] : ''
// var link = document.createElement('a')
if (link.parentNode) {
document.body.removeChild(link)
}
})
// link.href = `https://swlab.bwg.co.kr/web/dms/download-file?filename=${filename}.zip&directory=${directory}`
// link.click()
// if (link.parentNode) {
// document.body.removeChild(link)
// }
// })
// downlaodMobile.addEventListener('click', function () {
// var pathname = window.location.pathname
// var path = pathname.split('/')
// var isInternal = path[4].includes('-s')
// var filename = path[3] ? path[3] === 'swlab-docs'
// ? 'docs' : isInternal ? `docs-${path[3]}-s` : `docs-${path[3]}` : ''
// var directory = path[3] && path[4] ? path[3] === 'swlab-docs' ? path[3] : path[4] : ''
// var link = document.createElement('a')
// link.href = `https://swlab.bwg.co.kr/web/dms/download-file?filename=${filename}.zip&directory=${directory}`
// link.click()
// if (link.parentNode) {
// document.body.removeChild(link)
// }
// })
})()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment