about.js
1 month ago
admin-notifications.js
1 month ago
settings.js
1 month ago
smash-usage-session.js
1 month ago
support.js
1 month ago
support.js
113 lines
| 1 | var support_data = { |
| 2 | genericText: ctf_support.genericText, |
| 3 | articles: ctf_support.articles, |
| 4 | links: ctf_support.links, |
| 5 | system_info: ctf_support.system_info, |
| 6 | system_info_n: ctf_support.system_info_n, |
| 7 | exportFeed: 'none', |
| 8 | feeds: ctf_support.feeds, |
| 9 | supportUrl: ctf_support.supportUrl, |
| 10 | socialWallActivated: ctf_support.socialWallActivated, |
| 11 | socialWallLinks: ctf_support.socialWallLinks, |
| 12 | siteSearchUrl: ctf_support.siteSearchUrl, |
| 13 | siteSearchUrlWithArgs: null, |
| 14 | searchKeywords: null, |
| 15 | buttons: ctf_support.buttons, |
| 16 | links: ctf_support.links, |
| 17 | supportPageUrl: ctf_support.supportPageUrl, |
| 18 | systemInfoBtnStatus: 'collapsed', |
| 19 | copyBtnStatus: null, |
| 20 | ajax_handler: ctf_support.ajax_handler, |
| 21 | nonce: ctf_support.nonce, |
| 22 | icons: ctf_support.icons, |
| 23 | images: ctf_support.images, |
| 24 | svgIcons : ctf_support.svgIcons, |
| 25 | notificationElement : { |
| 26 | type : 'success', // success, error, warning, message |
| 27 | text : '', |
| 28 | shown : null |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | var ctfsupport = new Vue({ |
| 33 | el: "#ctf-support", |
| 34 | http: { |
| 35 | emulateJSON: true, |
| 36 | emulateHTTP: true |
| 37 | }, |
| 38 | data: support_data, |
| 39 | methods: { |
| 40 | copySystemInfo: function() { |
| 41 | let self = this; |
| 42 | const el = document.createElement('textarea'); |
| 43 | el.className = 'ctf-fb-cp-clpboard'; |
| 44 | el.value = self.system_info_n; |
| 45 | document.body.appendChild(el); |
| 46 | el.select(); |
| 47 | document.execCommand('copy'); |
| 48 | document.body.removeChild(el); |
| 49 | this.notificationElement = { |
| 50 | type : 'success', |
| 51 | text : this.genericText.copiedToClipboard, |
| 52 | shown : "shown" |
| 53 | }; |
| 54 | |
| 55 | setTimeout(function() { |
| 56 | this.notificationElement.shown = "hidden"; |
| 57 | }.bind(self), 3000); |
| 58 | }, |
| 59 | expandSystemInfo: function() { |
| 60 | this.systemInfoBtnStatus = ( this.systemInfoBtnStatus == 'collapsed' ) ? 'expanded' : 'collapsed'; |
| 61 | }, |
| 62 | expandBtnText: function() { |
| 63 | if ( this.systemInfoBtnStatus == 'collapsed' ) { |
| 64 | return this.buttons.expand; |
| 65 | } else if ( this.systemInfoBtnStatus == 'expanded' ) { |
| 66 | return this.buttons.collapse; |
| 67 | } |
| 68 | }, |
| 69 | exportFeedSettings: function() { |
| 70 | // return if no feed is selected |
| 71 | if ( this.exportFeed === 'none' ) { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | let url = this.ajax_handler + '?action=ctf_export_settings_json&feed_id=' + this.exportFeed; |
| 76 | window.location = url; |
| 77 | }, |
| 78 | searchDoc: function() { |
| 79 | let self = this; |
| 80 | let searchInput = document.getElementById('ctf-search-doc-input'); |
| 81 | searchInput.addEventListener('keyup', function ( event ) { |
| 82 | let url = new URL( self.siteSearchUrl ); |
| 83 | let search_params = url.searchParams; |
| 84 | if ( self.searchKeywords ) { |
| 85 | search_params.set('search', self.searchKeywords); |
| 86 | } |
| 87 | search_params.set('plugin', 'twitter'); |
| 88 | url.search = search_params.toString(); |
| 89 | self.siteSearchUrlWithArgs = url.toString(); |
| 90 | |
| 91 | if ( event.key === 'Enter' ) { |
| 92 | window.open( self.siteSearchUrlWithArgs, '_blank'); |
| 93 | } |
| 94 | }) |
| 95 | }, |
| 96 | searchDocStrings: function() { |
| 97 | let self = this; |
| 98 | let url = new URL( this.siteSearchUrl ); |
| 99 | let search_params = url.searchParams; |
| 100 | setTimeout(function() { |
| 101 | search_params.set('search', self.searchKeywords); |
| 102 | search_params.set('plugin', 'twitter'); |
| 103 | url.search = search_params.toString(); |
| 104 | self.siteSearchUrlWithArgs = url.toString(); |
| 105 | }, 10); |
| 106 | }, |
| 107 | goToSearchDocumentation: function() { |
| 108 | if ( this.searchKeywords !== null && this.siteSearchUrlWithArgs !== null ) { |
| 109 | window.open( this.siteSearchUrlWithArgs, '_blank'); |
| 110 | } |
| 111 | }, |
| 112 | }, |
| 113 | }) |