Last active
October 8, 2015 09:45
-
-
Save flackend/9f2956f3d682f9099e47 to your computer and use it in GitHub Desktop.
Revisions
-
flackend revised this gist
Oct 8, 2015 . No changes.There are no files selected for viewing
-
flackend revised this gist
Oct 8, 2015 . No changes.There are no files selected for viewing
-
flackend revised this gist
Oct 8, 2015 . No changes.There are no files selected for viewing
-
flackend created this gist
Oct 8, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,68 @@ // GENERATE function getScript(url, callback) { var head = document.documentElement, script = document.createElement('script'), done = false; script.src = url; script.onload = script.onreadystatechange = function() { if(!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { done = true; if(callback !== undefined) { callback(); } script.onload = script.onreadystatechange = null; if(head && script.parentNode) { head.removeChild(script); } } }; head.insertBefore(script, head.firstChild); return undefined; } // Get jQuery getScript('https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', function() { $('[name="lolfmkbox_portfolio_type"]').attr('id', 'lolfmkbox_portfolio_type'); var fieldIds = [ 'title', 'content', 'lolfmkbox_portfolio_type', 'lolfmkbox_gallery_shortcode', 'lolfmkbox_portfolio_desc', 'lolfmkbox_portfolio_date', 'lolfmkbox_portfolio_date_label', 'lolfmkbox_portfolio_client', 'lolfmkbox_portfolio_client_label', 'lolfmkbox_portfolio_skills', 'lolfmkbox_portfolio_skills_label', 'lolfmkbox_portfolio_url', 'lolfmkbox_portfolio_url_label', 'slide_template', 'yoast_wpseo_focuskw', 'yoast_wpseo_title', 'yoast_wpseo_metadesc' ]; var fields = {}; for (var i in fieldIds) { fields[fieldIds[i]] = $('#' + fieldIds[i]).val(); } var tags = []; $('.tagchecklist span').each(function() { $(this).find('a').remove(); tags.push($(this).text()); }); fields['new-tag-portfolio-categories'] = tags.join(','); console.log(JSON.stringify(fields)); }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ // POPULATE function getScript(url, callback) { var head = document.documentElement, script = document.createElement('script'), done = false; script.src = url; script.onload = script.onreadystatechange = function() { if(!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) { done = true; if(callback !== undefined) { callback(); } script.onload = script.onreadystatechange = null; if(head && script.parentNode) { head.removeChild(script); } } }; head.insertBefore(script, head.firstChild); return undefined; } // Get jQuery getScript('https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js', function() { // Add ID for type $('[name="lolfmkbox_portfolio_type"]').attr('id', 'lolfmkbox_portfolio_type'); // Loop and set values for (var i in d) { if (i == 'content') { console.log('setting content', d[i]); tinyMCE.activeEditor.setContent(d[i]); } else { console.log('find #' + i + ' and set to ' + d[i]); $('body').find('#' + i).val(d[i]); } } $('#lolfmkbox_portfolio_type').change(); });