top of page

Forum Posts

Toby
Jun 09, 2022
In Coding with Velo
I’m having trouble populating a text field (within a repeater) with a date, which needs to be retrieved from a database. Here is the text element on the page see the ID “formDate” Here is the database Field Key and database screenshot. Note the Field Key is “dateField”. Here is my code: $w.onReady(function () { console.log("Start"); // Get the date from the date field of the current item const date = $w("#dynamicDataset").getCurrentItem().dateField; // Sets formatting options for date console.log(date); const options = { day: "numeric", month: "long", year: "numeric" }; console.log("Set date paramaters"); // Sets the property of the text element to be a string representing the date in AU English $w("#formDate").text = date.toLocaleDateString("en-AU", options); console.log("Converted date to text"); $w("#VSIRrepeater").onItemReady( ($w, itemData, index) => { if($w("#formDescription").text == ""){ $w("#formDescription").collapse(); } console.log("Collapsed description (if needed)"); if($w("#formDate").text == ""){ $w("#formDate").collapse(); } console.log("Collapsed date (if needed)"); }); }); Based on the console log, it looks like it’s getting stuck at line 4. I suspect it is having an issue retrieving the date from the database, but I can't figure out why as no errors are displayed. I have also double-checked that the repeater's ID is "dynamicDataset". I followed this tutorial for the date retrieval and formatting - https://support.wix.com/en/article/velo-formatting-dates Any help would be greatly appreciated. Thank you
Issue Displaying Date in Text Elements (From Database) content media
0
0
23
Toby
Aug 10, 2020
In Coding with Velo
I am trying to get a dropdown element to open a URL in a new window. The URL is generated based on the user's selection. The value of each selection/choice is the URL that should be opened (see image below for configuration). I have reviewed the documentation at the following link - https://www.wix.com/corvid/reference/$w/linkablemixin but the code is throwing the error "'target' does not exist on '#headerlogin'. Below is my code. export function headerlogin_change(event) { let url = $w("#headerlogin").value; $w("#headerlogin").link = url; $w("#headerlogin").target = "_blank"; } I should also note that I originally tried to use wix-location, but as far as I can tell it doesn't allow links to be opened in a new window. Any clarification would be appreciated, thank you
Get dropdown element to open URL in new window content media
0
5
255
Toby
Jun 21, 2018
In Coding with Velo
Hi, I'm trying to find a method of encrypting a string with HMAC SHA-1 Base16 but can't seem to find any method that WiX supports currently. I find this surprising due to how important security is to WiX, so presumably there's a means to achieve this? The only reference I can find inside WiX documentation is https://dev.wix.com/docs/infrastructure/app-instance/parsing-examples/ which doesn't seem to relate to Wix-Code. Any assistance with this would be greatly appreciated, or if there is not currently a means to achieve this then I would appreciate knowing when you plan to integrate it. Thanks! EDIT: I have found a way to achieve this (for use in oAuth 1.0 signature generation) I found a compressed javascript snippet online that works as intended: If you paste this into your javascript file in the backend b64_hmac_sha1 = function(k,d,_p,_z){ // heavily optimized and compressed version of http://pajhome.org.uk/crypt/md5/sha1.js // _p = b64pad, _z = character size; not used here but I left them available just in case if(!_p){_p='=';}if(!_z){_z=8;}function _f(t,b,c,d){if(t<20){return(b&c)|((~b)&d);}if(t<40){return b^c^d;}if(t<60){return(b&c)|(b&d)|(c&d);}return b^c^d;}function _k(t){return(t<20)?1518500249:(t<40)?1859775393:(t<60)?-1894007588:-899497514;}function _s(x,y){var l=(x&0xFFFF)+(y&0xFFFF),m=(x>>16)+(y>>16)+(l>>16);return(m<<16)|(l&0xFFFF);}function _r(n,c){return(n<<c)|(n>>>(32-c));}function _c(x,l){x[l>>5]|=0x80<<(24-l%32);x[((l+64>>9)<<4)+15]=l;var w=[80],a=1732584193,b=-271733879,c=-1732584194,d=271733878,e=-1009589776;for(var i=0;i<x.length;i+=16){var o=a,p=b,q=c,r=d,s=e;for(var j=0;j<80;j++){if(j<16){w[j]=x[i+j];}else{w[j]=_r(w[j-3]^w[j-8]^w[j-14]^w[j-16],1);}var t=_s(_s(_r(a,5),_f(j,b,c,d)),_s(_s(e,w[j]),_k(j)));e=d;d=c;c=_r(b,30);b=a;a=t;}a=_s(a,o);b=_s(b,p);c=_s(c,q);d=_s(d,r);e=_s(e,s);}return[a,b,c,d,e];}function _b(s){var b=[],m=(1<<_z)-1;for(var i=0;i<s.length*_z;i+=_z){b[i>>5]|=(s.charCodeAt(i/8)&m)<<(32-_z-i%32);}return b;}function _h(k,d){var b=_b(k);if(b.length>16){b=_c(b,k.length*_z);}var p=[16],o=[16];for(var i=0;i<16;i++){p[i]=b[i]^0x36363636;o[i]=b[i]^0x5C5C5C5C;}var h=_c(p.concat(_b(d)),512+d.length*_z);return _c(o.concat(h),512+160);}function _n(b){var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s='';for(var i=0;i<b.length*4;i+=3){var r=(((b[i>>2]>>8*(3-i%4))&0xFF)<<16)|(((b[i+1>>2]>>8*(3-(i+1)%4))&0xFF)<<8)|((b[i+2>>2]>>8*(3-(i+2)%4))&0xFF);for(var j=0;j<4;j++){if(i*8+j*6>b.length*32){s+=_p;}else{s+=t.charAt((r>>6*(3-j))&0x3F);}}}return s;}function _x(k,d){return _n(_h(k,d));}return _x(k,d); } You can invoke the function by using b64_hmac_sha1(<key>, <unencrypted signature string>);
1
0
382
Toby
Mar 09, 2018
In Coding with Velo
Hi, I have implemented a preloader to my Wix website which is displayed when a visitor first loads my website https://www.tobymcdowell.com The problem I am having is that my mobile menu is being displayed in front of the preloader. The interesting part is that other Wix users who have have implemented the same preloader code do not have the mobile menu overlaying the preloader. Some examples are: www.futurevisionweb.com www.reverseweb.ch www.simplytelecom.co.uk Please see the image below to see what happens when loading the mobile version of my website. The preloader code is also below: <div id="preloader"> <div id="loader"></div> </div> <style media="screen and (max-width: 200px)"> /* Transparent Overlay */ #loading:before { content: ''; display: block; position: absolute; top: 0; left: 0; width: 50%; height: 50%; background-color: rgba(0,0,0,0.3); } #preloader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; } #loader { display: block; position: relative; left: 50%; top: 50%; width: 100px; height: 100px; margin: -50px 0 0 -50px; border-radius: 50%; border: 3px solid transparent; border-top-color: #22556C; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } #loader:before { content: ""; position: absolute; top: 5px; left: 5px; right: 5px; bottom: 5px; border-radius: 50%; border: 3px solid transparent; border-top-color: #398EB5; -webkit-animation: spin 3s linear infinite; animation: spin 3s linear infinite; } #loader:after { content: ""; position: absolute; top: 15px; left: 15px; right: 15px; bottom: 15px; border-radius: 50%; border: 3px solid transparent; border-top-color: #88BBD2; -webkit-animation: spin 1.5s linear infinite; animation: spin 1.5s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes spin { 0% { -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); } } </style> <style media="screen and (min-width: 200px)"> /* Transparent Overlay */ #loading:before { content: ''; display: block; position: absolute; top: 0; left: 0; width: 50%; height: 50%; background-color: rgba(0,0,0,0.3); } #preloader { position: fixed; top: 0; left: 0; width: 100%; height: 100%; } #loader { display: block; position: relative; left: 50%; top: 50%; width: 150px; height: 150px; margin: -75px 0 0 -75px; border-radius: 50%; border: 3px solid transparent; border-top-color: #22556C; -webkit-animation: spin 2s linear infinite; animation: spin 2s linear infinite; } #loader:before { content: ""; position: absolute; top: 5px; left: 5px; right: 5px; bottom: 5px; border-radius: 50%; border: 3px solid transparent; border-top-color: #398EB5; -webkit-animation: spin 3s linear infinite; animation: spin 3s linear infinite; } #loader:after { content: ""; position: absolute; top: 15px; left: 15px; right: 15px; bottom: 15px; border-radius: 50%; border: 3px solid transparent; border-top-color: #88BBD2; -webkit-animation: spin 1.5s linear infinite; animation: spin 1.5s linear infinite; } @-webkit-keyframes spin { 0% { -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); } } @keyframes spin { 0% { -webkit-transform: rotate(0deg); -ms-transform: rotate(0deg); transform: rotate(0deg); } 100% { -webkit-transform: rotate(360deg); -ms-transform: rotate(360deg); transform: rotate(360deg); } } </style> Any help would be greatly appreciated. Thank you
Mobile menu displaying on top of preloader content media
0
0
106
Toby
Mar 09, 2018
In Coding with Velo
Hi, I have implemented a CSS preloader using the HTML insert element for the portfolio page of my website, so tht when a different tab is clicked the preloader appears while the repeater content is loaded in. The problem I am having is that the preloader is always displaying on Safari desktop. On Safari mobile, Firefox (desktop & mobile), and Chrome (desktop & mobile) it is functioning correctly. Please see the following GIF. Please see the following image to see how it looks in the editor. Please see my code for the preloader to display and hide. export function ShowLoadingCSS($w) { $w("#repeater1").hide().then(() => { $w("#imgPreloader").show(); }); } export function HideLoadingCSS($w) { $w("#imgPreloader").hide().then(() => { $w("#repeater1").show(); }); } Any help would be greatly appreciated. Thank you
Element not hiding on Safari (desktop only) content media
0
6
129
Toby
Feb 07, 2018
In Coding with Velo
Hi, I'm currently having an issue resetting a dataset to only display the default "Number of Items to Display" after changing tabs and coming back. The example in question can be found here: https://www.tobymcdowell.com/portfolio Scrolling down on the All tab and clicking "See More" adds 9 items to the list using the loadMore() function. Going on to different tabs does not refresh the amount of items visible from 18 (since "See More" was pressed) to 9 (the default amount of records displayed). Returning to the "All" tab shows 18 items in the list, where I would prefer it be the default value Is there a way to achieve this? Here is my button code: // Changes tab based on parameters, disables button pressed export function SelectCategory($w, _prevSelection, filter, category) { $w(prvSelection).enable(); prvSelection = _prevSelection; $w(_prevSelection).disable(); $w("#btnSeeMore").hide(); // Display preloader ShowLoadingGif($w); // Change filter $w("#dataset1").setFilter(wixData.filter() .contains(filter, category) ); // Refresh and remove the preloader after completion $w("#dataset1").refresh().then ( () => { // Reset 'See More' button SetSeeMoreButtonDisplay($w); HideLoadingGif($w); }); } I have searched the WixCode API and as far as I can tell no property exists to change or read the "Number of Items to Display" property of the data set. I have also tried clearing the repeater that is attached to the Dataset but that doesn't work either. Any help would be greatly appreciated!
0
7
767
Toby
Dec 20, 2017
In Coding with Velo
Hi, I have recently integrated anchors into my site for quality of life purposes, namely with folding elements. Unfortunately, I am having some issues when my anchor that I am travelling to is far down the page. The intended result is a smooth transition to the anchor, but the actual result is a jerky snap to the bottom of the page. This is illustrated in the clip shown, where I first show it working as it should, then what happens when clicking on a fold that is further down the page: Here is my relevant current code, using the functionality found in a Wix-Code tutorial on folds. function toggleFold(index) { let $fold = $w('#fold' + index); // Store the anchor required let $anchor = $w('#ncr' + index); let $arrowDown = $w('#arrowDown' + index); let $arrowRight = $w('#arrowRight' + index); // toggle the fold at the index if ($fold.collapsed) { $fold.expand(); // Scroll to the anchor $anchor.scrollTo(); $arrowDown.show(); $arrowRight.hide(); } else { $fold.collapse(); $arrowDown.hide(); $arrowRight.show(); } // collapse the other folds [1, 2, 3, 4] .filter(idx => idx !== index) .forEach(idx => { $w('#fold' + idx).collapse(); $w('#arrowDown' + idx).hide(); $w('#arrowRight' + idx).show(); }); } The anchor names and numbers match up with the fold numbers, so the index cannot be the issue. Any ideas?
Anchor.scrollTo() functioning strangely content media
0
6
1k
Toby
Dec 12, 2017
In Coding with Velo
Hi, I am performing input validation and am using the text field value to check whether the user has entered any data. Unfortunately, it seems that the value is not being updated PRIOR to performing onKeyPress but rather AFTER. This can be seen through the below: The text is inputted as above, and below is the output Here is my code: $w.onReady(function () { $w("#txtFName").onKeyPress((eventHandler) => { console.log("Value of First Name: " + $w("#txtFName").value); if($w("#txtFName").value !== "") $w("#text27").collapse(); }); $w("#txtLName").onKeyPress((eventHandler) => { console.log("Value of Last Name: " + $w("#txtLName").value); if($w("#txtLName").value.length > 0) $w("#text29").collapse(); }); }); I have tried two different variations of checking the value (by both length and contents) The outcome is the same on both. Am I missing something, or am I correct in assuming that the value is not being changed before onKeyPress is called? If I am correct, is there another way to set this up? I wish to have my error box disappear when the user enter a value into the box, without needing to click out of the box to apply the change.
Text Field value not updating correctly using onKeyPress content media
0
4
457
Toby
Dec 08, 2017
In Coding with Velo
I'm trying to use a database hook to send information to a MailChimp list. The problem is that my code stops continuing at a certain point (processing the httpResponse) export function sendToMailChimp(data) { return fetch("https://us4.api.mailchimp.com/3.0/lists/" + LIST_ID + "/members", { method: 'post', headers: { 'Authentication': 'webForm:' + API_KEY, 'content-type': 'application/json' }, body: data }).then((httpResponse) => {console.log("Status: " + httpResponse.statusText);}); } The console does not show the "Status: " message. If I run the following, "Handle response" is printed but still not the "Status: " message: export function sendToMailChimp(data) { return fetch("https://us4.api.mailchimp.com/3.0/lists/" + LIST_ID + "/members", { method: 'post', headers: { 'anystring': '' + API_KEY, 'content-type': 'application/json' }, body: data }).then("Handle response").then((httpResponse) => {console.log("Status: " + httpResponse.statusText);}); } In addition to this, the data is presumably rejected by MailChimp as it isn't there when I look for it. It may be an authentication issue but there's no documentation online on setting up mailchimp and I cannot seem to find a way of doing basic authentication for my API_KEY other than what I have written, so I am in the dark. Is anyone able to provide some insight as to what may be going wrong? Thank you.
1
28
3k
Toby
Dec 07, 2017
In Coding with Velo
Hi, I have created some simple form validation to validate a form. The validation works as it should, the problem I am having is that after the form successfully submits, the error error messages appear, even though the form contains no content. please see attached screen shot. I feel like something is happing with the Wix Code form validation that is conflicting with my validation. Any help would be appreciated. ------------------------------------------------CODE ------------------------------------------------------ export function input1_blur(event, $w) { // Name $w("#input1").onCustomValidation((value, reject) => { if (value.length === 0) { reject("Please enter a name"); $w("#text27").show(); } else { $w("#text27").hide(); } }); } export function input2_blur(event, $w) { // Email $w("#input2").onCustomValidation((value, reject) => { if (value.length === 0) { reject("Please enter a valid E-Mail address."); $w("#text28").text = "Please enter an E-Mail address"; $w("#text28").show(); } else if (!value.includes("@") || !value.includes(".")) { reject("A valid E-Mail address is required."); $w("#text28").text = "A valid email address is required"; $w("#text28").show(); } else $w("#text28").hide(); }); } ------------------------------------------------CODE ------------------------------------------------------
Wix Code - Form Validation Error content media
0
3
3k
Toby
Dec 06, 2017
In Coding with Velo
Hi, I am attempting to integrate the Wix Code form so that when it submits the name and email are send to MailChimp through the REST API. I have created the form (ssee attachment) and linked it to the Wix Code database, however I am having difficulty adding the MailChimp API. The visitor would select a check box if they want to opt-in for mailchimp subscription. Any help you be appreciated.
Integrate Wix Code Form With MailChimp API content media
0
3
1k

Toby

More actions
bottom of page