{"id":20713015,"url":"https://github.com/carolcoral/lcript","last_synced_at":"2025-05-10T21:32:56.066Z","repository":{"id":99859015,"uuid":"140576448","full_name":"carolcoral/Lcript","owner":"carolcoral","description":"A simple script for HTML to do.Welcome to propose your suggestions or opinions！","archived":true,"fork":false,"pushed_at":"2018-11-14T12:45:57.000Z","size":490,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T06:49:17.214Z","etag":null,"topics":["javascript","lcript","search","web"],"latest_commit_sha":null,"homepage":"https://carolcoral.github.io/Lcript/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carolcoral.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-11T13:06:37.000Z","updated_at":"2024-09-26T02:13:21.000Z","dependencies_parsed_at":"2023-05-10T19:00:06.896Z","dependency_job_id":null,"html_url":"https://github.com/carolcoral/Lcript","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carolcoral%2FLcript","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carolcoral%2FLcript/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carolcoral%2FLcript/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carolcoral%2FLcript/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carolcoral","download_url":"https://codeload.github.com/carolcoral/Lcript/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253486103,"owners_count":21916130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","lcript","search","web"],"created_at":"2024-11-17T02:23:02.579Z","updated_at":"2025-05-10T21:32:56.061Z","avatar_url":"https://github.com/carolcoral.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lcript\n\nA simple script for HTML to do.Welcome to propose your suggestions or opinions！\n\n[TOC]\n\n## Version:0.1\n### Features\n        \n1.\u003ca href=\"#fuzzy_search_ajax\"\u003eFuzzy search for ajax(Highlighted Search results)\u003c/a\u003e\n\n2.\u003ca href=\"#hidden_click\"\u003eClick blank to hide search results\u003c/a\u003e\n\n3.\u003ca href=\"#strim\"\u003eRemove the white space on both sides of the string\u003c/a\u003e\n\n4.\u003ca href=\"#alert_text\"\u003ePop up the text text in the specified element\u003c/a\u003e\n\n## How to use\n\n* Use it in HTML\n```javascript\n        \u003cscript type=\"application/javascript\" src=\"/src/js/lcript.js\"\u003e\u003c/script\u003e\n```\n* Use it in NodeJS/Webpack\n```javascript\n        import lcript from './lcript'\n        window.lcript.alert('.test')\n```\n* Also,you can use these to do not only creating the same code always.\n```javascript\n        var lcript = window.lcript\n        lcript.alert('.test')\n```\n\n## \u003ca id=\"fuzzy_search_ajax\"\u003e1.Fuzzy search for ajax(Highlighted Search results)\u003c/a\u003e\n### 1.1 First all\n\n1.Import these scripts in your page.Beside the Bootstarp and the Jquery should be import at all of scripts first.But the style of Bootstrap is not must be.You can use your own css file.\n\n```javascript\n        \u003c!--have to import jquery first--\u003e\n        \u003cscript type=\"application/javascript\" src=\"/src/js/jquery/jquery.js\"\u003e\u003c/script\u003e\n        \u003c!--import bootstrap--\u003e\n        \u003cscript type=\"application/javascript\" src=\"/src/bootstrap/js/bootstrap.min.js\"\u003e\u003c/script\u003e\n```\n\n2.Then you can import this script in your page to do Search.\n\n```javascript\n        \u003c!--import search javascript--\u003e\n        \u003cscript type=\"application/javascript\" src=\"/src/js/search_box/js\"\u003e\u003c/script\u003e\n```\n\n3.Why we should have to import these script?\n\n        Because this script is based on the jquery to do .But you can not have to import the Bootstrap and import what you want a style or theme.\n        \n### 1.2 Then,use it in your page\n\n1.The following attributes are required\n\n```javascript\n        //type of get data,ajax or json\n        \"url\":\"/admin/tsg_fuzzy_search\",\n        //bind method to this element\n        \"el\":obj,\n        //show your have searched results\n        \"el_show\":\".selected_keywords\",\n        //refresh the search post time(in ms)\n        \"refresh\":200,\n        //set your own type for ajax\n        \"ajaxType\":\"post\",\n        //set the show-tab for search results,must be class,ul style\n        \"showTabStyle\":\"list-group\",\n        //li style\n        \"listGroupItem\":\"list-group-item\"\n```\n\n2.You can use it like this in your page,and add this code \u003ccode\u003eoninput=\"test(this)\"\u003c/code\u003e in your input box.Ofcourse,you can change the \u003ccode\u003e\"test\"\u003c/code\u003e to what you want.When you changed it,don't forget change the function's name too, please.\n\n```javascript\n        function test(obj){\n            lcript.search_ajax({\n                \"url\":\"/admin/tsg_fuzzy_search\",\n                \"el\":obj,\n                \"el_show\":\".selected_keywords\",\n                \"refresh\":200,\n                \"ajaxType\":\"post\",\n                \"showTabStyle\":\"list-group\",\n                \"listGroupItem\":\"list-group-item\"\n            })\n        }\n```\n\n### 1.3 Importent Notes\n\n1.You have to use \u003ccode\u003e\"keywords\"\u003c/code\u003e as your ajax request keyword\n\n2.If you want to do something for a search result,you can create a function which name is \u003ccode\u003e\"choise_one_template\"\u003c/code\u003e,then create some methods in it.Like this function:\n\n```javascript\n            //Add the selected template to the display bar\n            function choise_one_template(obj) {\n                //Get the value of the selection\n                var template_data = $(obj).text()\n                //Making HTML\n                var selected_template_html = \n                    \"\u003cbutton type='button' class='btn btn-default template_data' aria-label='Left Align'\u003e\"+\n                        \"\u003cspan class='glyphicon glyphicon-remove' aria-hidden='true' onclick='delete_template(this)'\u003e\u003c/span\u003e\"\n                        +selected_template+\n                    \"\u003c/button\u003e\"\n                //Insert HTML into the specified div\n                $(\"#results_2\").append(selected_template_html)\n            }\n```\n\n3.Request: use \u003ccode\u003e\"keywords\"\u003c/code\u003e as your request keyword.\n\n4.Response: \u003ccode\u003e\"data\"\u003c/code\u003e is must.If your datatype is json in this response, you have to edit the 102 line in lcript.js.\n\n```javascript\n    {   \n        \"code\":\"\",\n        \"msg\":\"\",\n        \"data\":\"\"\n    }\n```\n\n### 1.4 Demo to show it\n\n![](https://raw.githubusercontent.com/carolcoral/SaveImg/master/lcript.gif)\n\n## \u003ca id=\"hidden_click\"\u003e2.Click blank to hide search results\u003c/a\u003e\n\nIf you want to hidden the search-box when you click beside it,you can import these script in your page,and the \u003ccode\u003e\".selected_keywords\"\u003c/code\u003e is your show-tab of search results.\n\n```javascript\n        lcript.hidden(\".selected_keywords\")\n```\n\n## \u003ca id=\"strim\"\u003e3.Remove the white space on both sides of the string\u003c/a\u003e\n\nIf you want to pop the text content of the specified element, you can use this method \u003ccode\u003elcript.trim(str)\u003c/code\u003e to do it.\n\n```javascript\n        input:\n            lcript.trim(\"   test   \")\n        output:\n            \"test\"\n```\n\n## \u003ca id=\"alert_text\"\u003e4.Pop up the text text in the specified element\u003c/a\u003e\n\nIf you want to pop the text content of the specified element, you can use this method \u003ccode\u003elcript.alert(element)\u003c/code\u003e to do it.\n\n```javascript\n        input:\n            lcript.alert(\".selected_keywords\")\n        output:\n            \"test\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarolcoral%2Flcript","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarolcoral%2Flcript","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarolcoral%2Flcript/lists"}