diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7263098 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/node_modules/ +package-lock.json \ No newline at end of file diff --git a/dist/main.js b/dist/main.js new file mode 100644 index 0000000..4149e2a --- /dev/null +++ b/dist/main.js @@ -0,0 +1 @@ +(()=>{function t(t,e){for(var i=0;i { + this.constructLink(this.socialLink[e]) + }) + } + + constructLink = (arg) => { + let el = document.querySelectorAll(arg.selector) + let link = arg.link.replace("1%", this.link); + if(arg.args){ + arg.args.forEach((e,i)=>{ + link = link.replace((i+2)+"%", e) + }) + } + //set link + Array.prototype.forEach.call(el, (e) => { + e.setAttribute("href", link) + //set attribute + if (arg.attribute) + Object.keys(arg.attribute).forEach(att => { + e.setAttribute(att, arg.attribute[att]) + }) + + }) + } +} + + +new SocialMedia() \ No newline at end of file diff --git a/test/index.html b/test/index.html new file mode 100644 index 0000000..57b71e0 --- /dev/null +++ b/test/index.html @@ -0,0 +1,29 @@ + + + + + + + + Document + + + + + + + + + + \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..ab17a61 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,24 @@ +const path = require('path'); + +module.exports = { + mode: "production", + entry: './social-media.js', + output: { + filename: 'main.js', + path: path.resolve(__dirname, 'dist'), + }, + module: { + rules: [ + { + test: /\.m?js$/, + exclude: /(node_modules|bower_components)/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env'] + } + } + } + ] + } +}; \ No newline at end of file