Last active
September 15, 2015 21:28
-
-
Save ray-peters/b9a36e7fc105cc4cd53a to your computer and use it in GitHub Desktop.
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 characters
| /** | |
| * How to use: | |
| * Step 1: Navigate to the given template you're curious about and paste this in the console. | |
| * Step 2: ??? | |
| * Step 3: Profit | |
| * | |
| * @author Jonathan Preston <jp@ontraport.com>, Ray Peters <rpeters@ontraport.com> | |
| */ | |
| /** DO NOT TOUCH ANYTHING BELOW */ | |
| var optTemplateModel = ontraport.Models.Objects.getModel( 105 ), | |
| optEditor = ontraport.window.panel.currentPane.components.editor_component, | |
| optModel = optEditor.options.model, | |
| optUiState = optEditor.options.uiState, | |
| currentSplitTemplateId = optModel.resource[ optUiState.currentSelectedSplit ].templateId; | |
| if ( +currentSplitTemplateId === -1 ) { | |
| if ( confirm( "Sorry Charlie -- this template was MADE FROM SCRATCH!\n\n Copy block IDs to clipboard?" ) ) { | |
| var $iframe = $( ".opt-editor__canvas" ).contents(), | |
| $blocks = $iframe.find(".opt-row .opt-block-instance__selected .container[class*='block-style-'], .opt-row .opt-block-instance__selected .block-wrapper[class*='block-style-']"), | |
| ret = [], match, _class, | |
| _regex = /block\-style\-(\d+)/; | |
| for ( var i = 0, l = $blocks.length; i < l; ++i ) { | |
| _class = $blocks.eq( i ).attr( "class" ); | |
| match = _regex.exec( _class ); | |
| if ( match && match[1] ){ | |
| ret.push( match[1] ); | |
| } | |
| } | |
| copy( "Block IDs: " + ret.join( ", ") ); | |
| } | |
| } else { | |
| optTemplateModel.getOne( currentSplitTemplateId ).done( function( data ) { | |
| var msg; | |
| if ( currentSplitTemplateId > 60 ) { | |
| msg = "OPTv2 Template"; | |
| } else { | |
| msg = "OPTv1 Template"; | |
| } | |
| if ( confirm( msg + " :: " + data.data.name + "\n\nCopy template name to clipboard?" ) ) { | |
| copy( data.data.name ); | |
| } | |
| } ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment