### Initializing Swagger UI with Configuration - JavaScript Source: https://github.com/salesviewer/salesviewer-api/blob/master/assets/themes/hooligan/swagger-ui/index.html This JavaScript snippet initializes the Swagger UI instance on page load. It dynamically retrieves the API definition URL from the query string or defaults to a public Swagger example. It configures various display and interaction options, including supported HTTP methods, OAuth integration, and translation services. The `onComplete` and `onFailure` callbacks handle post-load actions and error reporting. ```JavaScript $(function () {\n var url = window.location.search.match(/url=([^&]+)/);\n if (url && url.length > 1) {\n url = decodeURIComponent(url[1]);\n } else {\n url = "http://petstore.swagger.io/v2/swagger.json";\n }\n hljs.configure({ highlightSizeThreshold: 5000 });\n // Pre load translate...\n if(window.SwaggerTranslator) {\n window.SwaggerTranslator.translate();\n }\n window.swaggerUi = new SwaggerUi({\n url: url,\n dom_id: "swagger-ui-container",\n supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],\n onComplete: function(swaggerApi, swaggerUi){\n if(typeof initOAuth == "function") {\n initOAuth({\n clientId: "your-client-id",\n clientSecret: "your-client-secret-if-required",\n realm: "your-realms",\n appName: "your-app-name",\n scopeSeparator: " ",\n additionalQueryStringParams: {}\n });\n }\n if(window.SwaggerTranslator) {\n window.SwaggerTranslator.translate();\n }\n },\n onFailure: function(data) {\n log("Unable to Load SwaggerUI");\n },\n docExpansion: "none",\n jsonEditor: false,\n defaultModelRendering: 'schema',\n showRequestHeaders: false,\n showOperationIds: false\n });\n window.swaggerUi.load();\n}); ``` -------------------------------- ### Initializing Google Analytics Tracking Source: https://github.com/salesviewer/salesviewer-api/blob/master/assets/themes/hooligan/css-social-buttons/sample.html This JavaScript code initializes Google Analytics tracking using the traditional `_gaq` asynchronous syntax. It sets the account ID, domain name, and tracks page views and page load times, ensuring data is sent to Google Analytics for website performance monitoring. ```JavaScript var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-25061452-1']); _gaq.push(['_setDomainName', 'smcllns.com']); _gaq.push(['_setAllowHash', 'false']); _gaq.push(['_trackPageview']); _gaq.push(['_trackPageLoadTime']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); ``` -------------------------------- ### Creating a Zocial Facebook Button with ``` -------------------------------- ### Embedding Twitter Widget JavaScript Source: https://github.com/salesviewer/salesviewer-api/blob/master/assets/themes/hooligan/css-social-buttons/sample.html This snippet initializes the Twitter widgets JavaScript library, allowing for the display of Twitter buttons and timelines on a webpage. It checks if the script is already loaded before injecting it into the DOM to prevent duplicate loads. ```JavaScript !function(d,s,id){ var js,fjs=d.getElementsByTagName(s)[0]; if(!d.getElementById(id)){ js=d.createElement(s); js.id=id; js.src="http://platform.twitter.com/widgets.js"; fjs.parentNode.insertBefore(js,fjs); } }(document,"script","twitter-wjs"); ``` -------------------------------- ### Creating a Zocial Twitter Button with Source: https://github.com/salesviewer/salesviewer-api/blob/master/assets/themes/hooligan/css-social-buttons/README.md This snippet shows how to create a Zocial social button for Twitter using an HTML `` (anchor) element. It utilizes the `.zocial` class for base styling and the `.twitter` class for the Twitter icon and branding, making it suitable for clickable links. ```HTML