I cannot integrate js query file in vue











up vote
0
down vote

favorite












i would like to use a js query code that I found on codepen in my vue project, but im not sure How to integrate it .
I simply pasted the file in my created() of my vue component but it doesn seem to work out.. the code is supposing to run a visual animation when typing chinese caractere in the input form.
this is the codepen : https://codepen.io/simeydotme/pen/CFcke



var $input = $('input');
$input.on({

"focus": function(e) {
$(".input-container").addClass("active");
},

"blur": function(e) {
$(".input-container").removeClass("active");
}

});

var previous = null;
setInterval( function() {
if( previous !== $input.val()
|| "" === $input.val()) {
getGoodCharacters( $input );
previous = $input.val();
}
}, 500);



function getGoodCharacters( $this ) {

var output = $this.val().trim();
var letters = output.split("");
var url = "https://service.goodcharacters.com/images/han/$$$.gif";

$(".error-container, .help").removeClass("show");
$(".output-container").empty();

for( letter in letters ) {

var img = letters[letter] + "";
var newurl = url.replace("$$$",img);
loadCharacter( newurl , img );

}

}

function loadCharacter( url , letter ) {

var img = new Image();
var $output = $(".output-container");
var $a = $("<a/>");
var l = $("input").val().length;

var cwidth = "120px";
if( l > 7 ) { cwidth = "70px"; }
else if( l > 6 ) { cwidth = "90px"; }
else if( l > 5 ) { cwidth = "100px"; }

$(img).load(function(){
$a.attr({
"href": url,
"title": "Good Character Chinese Symbol: "+ letter + ""
}).css("width", cwidth ).append( $(this) ).appendTo($output);
$(".help").addClass("show");
}).attr({
src: url
}).error(function(){
$(".error-container").addClass("show");
});

}


var $try = $(".tryme a").on("click", function(e) {

e.preventDefault();
$input.val( $(this).text() );

});


I also imported the jquery module in my componant



import $ from "jquery";


here is the html that i added in the template



 <div class="container input-container">

<input type="text" id="input" placeholder="中文" value="中文"/>

</div>




Thanks!










share|improve this question
























  • could you provide the pen where you find that code ?
    – Boussadjra Brahim
    Nov 11 at 1:19






  • 1




    yes this is the pen codepen.io/simeydotme/pen/CFcke thanks
    – romain1304
    Nov 11 at 1:28















up vote
0
down vote

favorite












i would like to use a js query code that I found on codepen in my vue project, but im not sure How to integrate it .
I simply pasted the file in my created() of my vue component but it doesn seem to work out.. the code is supposing to run a visual animation when typing chinese caractere in the input form.
this is the codepen : https://codepen.io/simeydotme/pen/CFcke



var $input = $('input');
$input.on({

"focus": function(e) {
$(".input-container").addClass("active");
},

"blur": function(e) {
$(".input-container").removeClass("active");
}

});

var previous = null;
setInterval( function() {
if( previous !== $input.val()
|| "" === $input.val()) {
getGoodCharacters( $input );
previous = $input.val();
}
}, 500);



function getGoodCharacters( $this ) {

var output = $this.val().trim();
var letters = output.split("");
var url = "https://service.goodcharacters.com/images/han/$$$.gif";

$(".error-container, .help").removeClass("show");
$(".output-container").empty();

for( letter in letters ) {

var img = letters[letter] + "";
var newurl = url.replace("$$$",img);
loadCharacter( newurl , img );

}

}

function loadCharacter( url , letter ) {

var img = new Image();
var $output = $(".output-container");
var $a = $("<a/>");
var l = $("input").val().length;

var cwidth = "120px";
if( l > 7 ) { cwidth = "70px"; }
else if( l > 6 ) { cwidth = "90px"; }
else if( l > 5 ) { cwidth = "100px"; }

$(img).load(function(){
$a.attr({
"href": url,
"title": "Good Character Chinese Symbol: "+ letter + ""
}).css("width", cwidth ).append( $(this) ).appendTo($output);
$(".help").addClass("show");
}).attr({
src: url
}).error(function(){
$(".error-container").addClass("show");
});

}


var $try = $(".tryme a").on("click", function(e) {

e.preventDefault();
$input.val( $(this).text() );

});


I also imported the jquery module in my componant



import $ from "jquery";


here is the html that i added in the template



 <div class="container input-container">

<input type="text" id="input" placeholder="中文" value="中文"/>

</div>




Thanks!










share|improve this question
























  • could you provide the pen where you find that code ?
    – Boussadjra Brahim
    Nov 11 at 1:19






  • 1




    yes this is the pen codepen.io/simeydotme/pen/CFcke thanks
    – romain1304
    Nov 11 at 1:28













up vote
0
down vote

favorite









up vote
0
down vote

favorite











i would like to use a js query code that I found on codepen in my vue project, but im not sure How to integrate it .
I simply pasted the file in my created() of my vue component but it doesn seem to work out.. the code is supposing to run a visual animation when typing chinese caractere in the input form.
this is the codepen : https://codepen.io/simeydotme/pen/CFcke



var $input = $('input');
$input.on({

"focus": function(e) {
$(".input-container").addClass("active");
},

"blur": function(e) {
$(".input-container").removeClass("active");
}

});

var previous = null;
setInterval( function() {
if( previous !== $input.val()
|| "" === $input.val()) {
getGoodCharacters( $input );
previous = $input.val();
}
}, 500);



function getGoodCharacters( $this ) {

var output = $this.val().trim();
var letters = output.split("");
var url = "https://service.goodcharacters.com/images/han/$$$.gif";

$(".error-container, .help").removeClass("show");
$(".output-container").empty();

for( letter in letters ) {

var img = letters[letter] + "";
var newurl = url.replace("$$$",img);
loadCharacter( newurl , img );

}

}

function loadCharacter( url , letter ) {

var img = new Image();
var $output = $(".output-container");
var $a = $("<a/>");
var l = $("input").val().length;

var cwidth = "120px";
if( l > 7 ) { cwidth = "70px"; }
else if( l > 6 ) { cwidth = "90px"; }
else if( l > 5 ) { cwidth = "100px"; }

$(img).load(function(){
$a.attr({
"href": url,
"title": "Good Character Chinese Symbol: "+ letter + ""
}).css("width", cwidth ).append( $(this) ).appendTo($output);
$(".help").addClass("show");
}).attr({
src: url
}).error(function(){
$(".error-container").addClass("show");
});

}


var $try = $(".tryme a").on("click", function(e) {

e.preventDefault();
$input.val( $(this).text() );

});


I also imported the jquery module in my componant



import $ from "jquery";


here is the html that i added in the template



 <div class="container input-container">

<input type="text" id="input" placeholder="中文" value="中文"/>

</div>




Thanks!










share|improve this question















i would like to use a js query code that I found on codepen in my vue project, but im not sure How to integrate it .
I simply pasted the file in my created() of my vue component but it doesn seem to work out.. the code is supposing to run a visual animation when typing chinese caractere in the input form.
this is the codepen : https://codepen.io/simeydotme/pen/CFcke



var $input = $('input');
$input.on({

"focus": function(e) {
$(".input-container").addClass("active");
},

"blur": function(e) {
$(".input-container").removeClass("active");
}

});

var previous = null;
setInterval( function() {
if( previous !== $input.val()
|| "" === $input.val()) {
getGoodCharacters( $input );
previous = $input.val();
}
}, 500);



function getGoodCharacters( $this ) {

var output = $this.val().trim();
var letters = output.split("");
var url = "https://service.goodcharacters.com/images/han/$$$.gif";

$(".error-container, .help").removeClass("show");
$(".output-container").empty();

for( letter in letters ) {

var img = letters[letter] + "";
var newurl = url.replace("$$$",img);
loadCharacter( newurl , img );

}

}

function loadCharacter( url , letter ) {

var img = new Image();
var $output = $(".output-container");
var $a = $("<a/>");
var l = $("input").val().length;

var cwidth = "120px";
if( l > 7 ) { cwidth = "70px"; }
else if( l > 6 ) { cwidth = "90px"; }
else if( l > 5 ) { cwidth = "100px"; }

$(img).load(function(){
$a.attr({
"href": url,
"title": "Good Character Chinese Symbol: "+ letter + ""
}).css("width", cwidth ).append( $(this) ).appendTo($output);
$(".help").addClass("show");
}).attr({
src: url
}).error(function(){
$(".error-container").addClass("show");
});

}


var $try = $(".tryme a").on("click", function(e) {

e.preventDefault();
$input.val( $(this).text() );

});


I also imported the jquery module in my componant



import $ from "jquery";


here is the html that i added in the template



 <div class="container input-container">

<input type="text" id="input" placeholder="中文" value="中文"/>

</div>




Thanks!







vue.js vuejs2 vue-component






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 11 at 1:29

























asked Nov 11 at 1:14









romain1304

11




11












  • could you provide the pen where you find that code ?
    – Boussadjra Brahim
    Nov 11 at 1:19






  • 1




    yes this is the pen codepen.io/simeydotme/pen/CFcke thanks
    – romain1304
    Nov 11 at 1:28


















  • could you provide the pen where you find that code ?
    – Boussadjra Brahim
    Nov 11 at 1:19






  • 1




    yes this is the pen codepen.io/simeydotme/pen/CFcke thanks
    – romain1304
    Nov 11 at 1:28
















could you provide the pen where you find that code ?
– Boussadjra Brahim
Nov 11 at 1:19




could you provide the pen where you find that code ?
– Boussadjra Brahim
Nov 11 at 1:19




1




1




yes this is the pen codepen.io/simeydotme/pen/CFcke thanks
– romain1304
Nov 11 at 1:28




yes this is the pen codepen.io/simeydotme/pen/CFcke thanks
– romain1304
Nov 11 at 1:28

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244990%2fi-cannot-integrate-js-query-file-in-vue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53244990%2fi-cannot-integrate-js-query-file-in-vue%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Florida Star v. B. J. F.

Danny Elfman

Lugert, Oklahoma